f5b632ed89
Reviewed-on: #397 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
35 行
851 B
TypeScript
35 行
851 B
TypeScript
import type { Transition } from 'framer-motion'
|
|
|
|
import type { ClientAnimationMode } from '@/lib/settings'
|
|
|
|
type ClientAnimationTransitionOptions = {
|
|
normal: Transition
|
|
reduced?: Transition
|
|
off?: Transition }
|
|
|
|
|
|
export const clientAnimationsOff = (
|
|
animationMode: ClientAnimationMode,
|
|
): boolean =>
|
|
animationMode === 'off'
|
|
|
|
|
|
export const clientAnimationTransition = (
|
|
animationMode: ClientAnimationMode,
|
|
{ normal, reduced, off }: ClientAnimationTransitionOptions,
|
|
): Transition => {
|
|
if (animationMode === 'off')
|
|
return off ?? { duration: 0 }
|
|
|
|
if (animationMode === 'reduced')
|
|
return reduced ?? { duration: .08, ease: 'linear' as const }
|
|
|
|
return normal
|
|
}
|
|
|
|
|
|
export const clientScrollBehaviour = (
|
|
animationMode: ClientAnimationMode,
|
|
): ScrollBehavior =>
|
|
animationMode === 'off' ? 'auto' : 'smooth'
|