// frontend\src\components\ui\teaserPlayback.ts export type TeaserPlaybackMode = 'still' | 'hover' | 'all' export type FinishedDownloadsTeaserState = { mode: TeaserPlaybackMode activeKey: string | null hoverKey: string | null audioEnabled: boolean } type TeaserAnimationOptions = { state: FinishedDownloadsTeaserState itemKey: string disabled?: boolean forceAll?: boolean } type TeaserAudioOptions = { state: FinishedDownloadsTeaserState itemKey: string inlineActive?: boolean disabled?: boolean } export function shouldObserveTeasers(mode: TeaserPlaybackMode): boolean { return mode === 'hover' || mode === 'all' } export function shouldAnimateTeaser({ state, itemKey, disabled = false, forceAll = false, }: TeaserAnimationOptions): boolean { if (disabled) return false if (forceAll) return true switch (state.mode) { case 'all': return true case 'hover': return state.hoverKey === itemKey case 'still': default: return false } } export function shouldEnableTeaserAudio({ state, itemKey, inlineActive = false, disabled = false, }: TeaserAudioOptions): boolean { if (disabled) return false if (!state.audioEnabled) return false // Inline immer bevorzugen if (inlineActive) return true // Desktop-Hover if (state.hoverKey === itemKey) return true // Mobile / aktiver Teaser im Viewport if (state.activeKey === itemKey) return true return false }