ファイル
btrc-hub/frontend/src/lib/clientAnimation.ts
T
2026-10-26 12:44:22 +09:00

41 行
1.0 KiB
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'
export const clientMotionTokens = {
durationMS: { feedback: 120, popover: 160, collapse: 220, reorder: 200, drop: 180 },
easing: [.2, 0, 0, 1] as const,
cssEasing: 'cubic-bezier(.2, 0, 0, 1)',
distance: 4 }