|
1 | 1 | import { onBeforeUnmount, unref, watch, type CSSProperties } from 'vue' |
2 | 2 |
|
3 | | -import { mergeDefined, isSSR } from './utils' |
| 3 | +import { mergeDefined, isSSR, isReducedMotion } from './utils' |
4 | 4 | import { CAPTURE_DELTA_FRAME_COUNT, defaultOptions } from './constants' |
5 | 5 |
|
6 | 6 | import type { UseFixedHeaderOptions, MaybeTemplateRef } from './types' |
7 | 7 |
|
8 | 8 | export function useFixedHeader( |
9 | 9 | target: MaybeTemplateRef, |
10 | | - options: Partial<UseFixedHeaderOptions> = defaultOptions |
| 10 | + options: Partial<UseFixedHeaderOptions> = defaultOptions, |
11 | 11 | ) { |
12 | 12 | const mergedOptions = mergeDefined(defaultOptions, options) |
13 | 13 |
|
@@ -115,12 +115,21 @@ export function useFixedHeader( |
115 | 115 |
|
116 | 116 | function onVisible() { |
117 | 117 | removeAriaHidden() |
118 | | - setStyles({ ...mergedOptions.enterStyles, visibility: '' as CSSProperties['visibility'] }) |
| 118 | + |
| 119 | + setStyles({ |
| 120 | + ...mergedOptions.enterStyles, |
| 121 | + visibility: '' as CSSProperties['visibility'], |
| 122 | + ...(isReducedMotion() ? { transition: 'none' } : {}), |
| 123 | + }) |
119 | 124 | } |
120 | 125 |
|
121 | 126 | function onHidden() { |
122 | 127 | setAriaHidden() |
123 | | - setStyles(mergedOptions.leaveStyles) |
| 128 | + |
| 129 | + setStyles({ |
| 130 | + ...mergedOptions.leaveStyles, |
| 131 | + ...(isReducedMotion() ? { transition: 'none' } : {}), |
| 132 | + }) |
124 | 133 | } |
125 | 134 |
|
126 | 135 | // Scroll |
@@ -300,7 +309,7 @@ export function useFixedHeader( |
300 | 309 |
|
301 | 310 | onCleanup(cleanListeners) |
302 | 311 | }, |
303 | | - { immediate: true, flush: 'post' } |
| 312 | + { immediate: true, flush: 'post' }, |
304 | 313 | ) |
305 | 314 |
|
306 | 315 | watch(mergedOptions.watch, toggleListeners, { flush: 'post' }) |
|
0 commit comments