Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed white blocks after shuffling + allowed reduced motion #1038

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question deleting this line may work why we are setting it to 0 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we don't need to set it to 0, I was just testing stuff and left it - transform and willChange is enough

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it doesn't change anything, as it's initially 0 too, so Ig it's up to reviewer to leave it or not ; )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it to 1px fixed the white blocks issue before which was why it was included FYI

document.body.style.paddingBottom = '0'
document.body.style.transform = 'none'
document.body.style.willChange = 'auto'
}
}, interval)
}
Expand Down
Loading