mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-22 14:09:30 -07:00
refactor: split monolithic state into context-based modules
Extract image, desktop, mobile, and config state into separate context providers to improve modularity and reduce unnecessary re-renders. Signed-off-by: Sped0n <hi@sped0n.com>
This commit is contained in:
64
assets/ts/mobile/galleryTransitions.ts
Normal file
64
assets/ts/mobile/galleryTransitions.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { type gsap } from 'gsap'
|
||||
|
||||
const OPEN_DELAY_MS = 1200
|
||||
const CLOSE_DELAY_MS = 1400
|
||||
|
||||
export function openGallery(args: {
|
||||
gsap: typeof gsap
|
||||
curtain: HTMLDivElement
|
||||
gallery: HTMLDivElement
|
||||
setIsAnimating: (value: boolean) => void
|
||||
setIsScrollLocked: (value: boolean) => void
|
||||
}): void {
|
||||
const { gsap, curtain, gallery, setIsAnimating, setIsScrollLocked } = args
|
||||
|
||||
setIsAnimating(true)
|
||||
|
||||
gsap.to(curtain, {
|
||||
opacity: 1,
|
||||
duration: 1
|
||||
})
|
||||
|
||||
gsap.to(gallery, {
|
||||
y: 0,
|
||||
ease: 'power3.inOut',
|
||||
duration: 1,
|
||||
delay: 0.4
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
setIsScrollLocked(true)
|
||||
setIsAnimating(false)
|
||||
}, OPEN_DELAY_MS)
|
||||
}
|
||||
|
||||
export function closeGallery(args: {
|
||||
gsap: typeof gsap
|
||||
curtain: HTMLDivElement
|
||||
gallery: HTMLDivElement
|
||||
setIsAnimating: (value: boolean) => void
|
||||
setIsScrollLocked: (value: boolean) => void
|
||||
onClosed: () => void
|
||||
}): void {
|
||||
const { gsap, curtain, gallery, setIsAnimating, setIsScrollLocked, onClosed } = args
|
||||
|
||||
setIsAnimating(true)
|
||||
|
||||
gsap.to(gallery, {
|
||||
y: '100%',
|
||||
ease: 'power3.inOut',
|
||||
duration: 1
|
||||
})
|
||||
|
||||
gsap.to(curtain, {
|
||||
opacity: 0,
|
||||
duration: 1.2,
|
||||
delay: 0.4
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
setIsScrollLocked(false)
|
||||
setIsAnimating(false)
|
||||
onClosed()
|
||||
}, CLOSE_DELAY_MS)
|
||||
}
|
||||
Reference in New Issue
Block a user