Skip to content

Commit

Permalink
Merge pull request #1038 from hackclub/reduce_motion
Browse files Browse the repository at this point in the history
Fixed white blocks after shuffling + allowed reduced motion
  • Loading branch information
malted authored Dec 25, 2024
2 parents 6362288 + 733f717 commit 7bd45f4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/harbor/battles/battles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export default function Matchups({ session }: { session: HsSession }) {
'https://cloud-1v9k8a4x7-hack-club-bot.vercel.app/0yr_sweep_up_01_audio.mp4',
].map((path) => new Howl({ src: path }))

const reducedMotion = window.matchMedia(
'(prefers-reduced-motion: reduce)',
).matches
let shuffling = false
function shuffle() {
shuffling = true
Expand All @@ -132,7 +135,7 @@ export default function Matchups({ session }: { session: HsSession }) {

document.body.style.willChange = 'transform'
let rotation = 0
const duration = 1000 // total duration in milliseconds
const duration = reducedMotion ? 0 : 1000 // total duration in milliseconds
const interval = 20 // interval in milliseconds
const totalSteps = duration / interval
let currentStep = 0
Expand Down Expand Up @@ -163,7 +166,10 @@ export default function Matchups({ session }: { session: HsSession }) {
if (currentStep >= totalSteps) {
clearInterval(spinInterval)
document.body.style.transform = 'rotate(0deg)' // reset to initial state
document.body.style.paddingTop = '1px'
document.body.style.paddingTop = '0'
document.body.style.paddingBottom = '0'
document.body.style.transform = 'none'
document.body.style.willChange = 'auto'
}
}, interval)
}
Expand Down

0 comments on commit 7bd45f4

Please sign in to comment.