Skip to content

Commit

Permalink
Merge pull request #154 from fedeperin/fix-konami-errors
Browse files Browse the repository at this point in the history
Fix konami errors
  • Loading branch information
midudev authored Feb 28, 2024
2 parents a813bc2 + b7b0a67 commit 3fcf9a1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
76 changes: 38 additions & 38 deletions src/components/KonamiCode.astro
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
<script defer>
const container = document.querySelector("body")

const konamiCode = [
"ArrowUp",
"ArrowUp",
"ArrowDown",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowLeft",
"ArrowRight",
"b",
"a",
]
let konamiCodePosition = 0

document.addEventListener("keydown", ({ key }) => {
const requiredKey = konamiCode[konamiCodePosition]

if (key != requiredKey) {
konamiCodePosition = 0
return
}

konamiCodePosition++

if (konamiCodePosition != konamiCode.length) return

container.style.transform = "rotateY(360deg)"
container.style.transition = "transform 3s ease"

container.addEventListener("transitionend", () => {
container.style.transition = "none"
container.style.transform = "rotateY(0deg)"
})

konamiCodePosition = 0
})
const container = document.querySelector("#main-content")

const konamiCode = [
"ArrowUp",
"ArrowUp",
"ArrowDown",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowLeft",
"ArrowRight",
"b",
"a",
]
let konamiCodePosition = 0

document.addEventListener("keydown", ({ key }) => {
const requiredKey = konamiCode[konamiCodePosition]

if (key !== requiredKey) {
konamiCodePosition = 0
return
}

konamiCodePosition++

if (konamiCodePosition !== konamiCode.length) return

container.style.transform = "rotateY(360deg)"
container.style.transition = "transform 2s ease"

container.addEventListener("transitionend", () => {
container.style.transition = ""
container.style.transform = ""
})

konamiCodePosition = 0
})
</script>
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const { title, description } = Astro.props
class="[&_:focus-visible]:outline-none [&_:focus-visible]:ring-2 [&_:focus-visible]:ring-primary"
>
<SmokeBackground />
<div class="mx-auto max-w-6xl px-2 pt-16 md:pt-20 lg:px-10">
<div class="mx-auto max-w-6xl px-2 pt-16 md:pt-20 lg:px-10" id="main-content">
<slot />
</div>
</body>
Expand Down

0 comments on commit 3fcf9a1

Please sign in to comment.