deja-vue 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +38 -211
- package/dist/index.js +83 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { Component, ComputedRef, InjectionKey, MaybeRef, MaybeRefOrGetter, Model
|
|
|
2
2
|
import { NodeRef } from "vue-unwrap";
|
|
3
3
|
import SplitText from "gsap/SplitText";
|
|
4
4
|
|
|
5
|
+
//#region src/composables/useReducedMotion.d.ts
|
|
6
|
+
type ReducedMotionMode = boolean | 'auto';
|
|
7
|
+
declare function useReducedMotion(mode?: MaybeRefOrGetter<ReducedMotionMode | undefined>): {
|
|
8
|
+
computed: import("vue").ComputedRef<boolean>;
|
|
9
|
+
system: import("vue").Ref<boolean, boolean>;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
5
12
|
//#region src/core/EventBus.d.ts
|
|
6
13
|
declare class EventBus<E extends string, A extends unknown[] = []> {
|
|
7
14
|
private bus;
|
|
@@ -14,11 +21,15 @@ declare class EventBus<E extends string, A extends unknown[] = []> {
|
|
|
14
21
|
}
|
|
15
22
|
//#endregion
|
|
16
23
|
//#region src/core/Animation.d.ts
|
|
24
|
+
type AnimationOptions = gsap.TimelineVars & {
|
|
25
|
+
reducedMotion?: boolean;
|
|
26
|
+
};
|
|
17
27
|
declare class Animation extends EventBus<AnimationEvent, [animation: Animation]> {
|
|
18
28
|
private ctx?;
|
|
19
29
|
private scrollTrigger?;
|
|
30
|
+
reducedMotion: boolean;
|
|
20
31
|
timeline: gsap.core.Timeline;
|
|
21
|
-
constructor(options?:
|
|
32
|
+
constructor(options?: AnimationOptions);
|
|
22
33
|
attachScrollTrigger(vars: ScrollTrigger.Vars | null | undefined): void;
|
|
23
34
|
compose(definition: AnimationComposeDefinition, withContext?: boolean): void;
|
|
24
35
|
add(child: AnimationChild, position?: gsap.Position, timeShift?: boolean): void;
|
|
@@ -44,21 +55,20 @@ interface DejaVueAnimationInstance extends DejaVueComponent {
|
|
|
44
55
|
controlled: boolean;
|
|
45
56
|
direction: Ref<AnimationDirection>;
|
|
46
57
|
parent: DejaVueAnimationParent | null;
|
|
58
|
+
reducedMotion: ComputedRef<boolean>;
|
|
47
59
|
progress: ModelRef<ControllableAnimation['progress']>;
|
|
48
60
|
}
|
|
49
61
|
interface DejaVueAnimationComponentProps {
|
|
62
|
+
reducedMotion?: ReducedMotionMode;
|
|
50
63
|
revertOnDispose?: boolean;
|
|
51
64
|
seamless?: boolean;
|
|
52
65
|
tweenTarget?: 'children' | 'self' | gsap.TweenTarget;
|
|
53
66
|
}
|
|
54
67
|
type DejaVueAnimationExposed = ShallowUnwrapRef<DejaVueAnimationInstance>;
|
|
55
68
|
type DejaVueAnimationParent = DejaVueAnimationInstance | DejaVueAnimationExposed;
|
|
56
|
-
type DejaVueAnimationScopeProps = Pick<DejaVueAnimationExposed, 'animation' | 'direction' | 'parent' | 'progress'>;
|
|
69
|
+
type DejaVueAnimationScopeProps = Pick<DejaVueAnimationExposed, 'animation' | 'direction' | 'parent' | 'progress' | 'reducedMotion'>;
|
|
57
70
|
type AnimationChild = Animation | gsap.Callback | string;
|
|
58
|
-
type
|
|
59
|
-
scope?: Element;
|
|
60
|
-
target: gsap.TweenTarget;
|
|
61
|
-
} & ({
|
|
71
|
+
type AnimationComposeTween = ({
|
|
62
72
|
method: 'fromTo';
|
|
63
73
|
vars: [gsap.TweenVars, gsap.TweenVars];
|
|
64
74
|
} | {
|
|
@@ -68,6 +78,10 @@ type AnimationComposeDefinition = {
|
|
|
68
78
|
method: string;
|
|
69
79
|
vars: Record<string, unknown>;
|
|
70
80
|
});
|
|
81
|
+
type AnimationComposeDefinition = {
|
|
82
|
+
scope?: Element;
|
|
83
|
+
target: gsap.TweenTarget;
|
|
84
|
+
} & AnimationComposeTween;
|
|
71
85
|
type AnimationDirection = 1 | -1 | 0;
|
|
72
86
|
type AnimationEvent = 'complete' | 'interrupt' | 'repeat' | 'reverseComplete' | 'start' | 'update';
|
|
73
87
|
type AnimationEventEmitter = (e: AnimationEvent, animation: Animation, parent: DejaVueAnimationParent | null) => void;
|
|
@@ -146,6 +160,10 @@ declare function toNonEmptyArray<T = unknown>(data: T[]): NonEmptyArray<T> | nul
|
|
|
146
160
|
//#endregion
|
|
147
161
|
//#region src/utils/gsap.d.ts
|
|
148
162
|
declare function applyTimelineTotalDuration(timeline: gsap.core.Timeline): void;
|
|
163
|
+
declare function getReducedMotionTween({
|
|
164
|
+
method,
|
|
165
|
+
vars
|
|
166
|
+
}: AnimationComposeTween): AnimationComposeTween | undefined;
|
|
149
167
|
declare function getScrollTriggerToggleActionByEvent(event: 'enter' | 'enterBack' | 'leave' | 'leaveBack', instance?: ScrollTrigger): string | undefined;
|
|
150
168
|
declare function isEmptyTarget(target: gsap.TweenTarget): boolean;
|
|
151
169
|
declare function resolveTimelinePosition(timeline: gsap.core.Timeline, position?: gsap.Position): number | null;
|
|
@@ -273,11 +291,11 @@ type __VLS_Slots$2 = {
|
|
|
273
291
|
default(props: DejaVueSplitTextScopeProps): any;
|
|
274
292
|
};
|
|
275
293
|
declare const __VLS_base$2: import("vue").DefineComponent<__VLS_Props, DejaVueSplitTextInstance, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
276
|
-
split: (splitText: SplitText) => any;
|
|
277
294
|
revert: (splitText: SplitText) => any;
|
|
295
|
+
split: (splitText: SplitText) => any;
|
|
278
296
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
279
|
-
onSplit?: ((splitText: SplitText) => any) | undefined;
|
|
280
297
|
onRevert?: ((splitText: SplitText) => any) | undefined;
|
|
298
|
+
onSplit?: ((splitText: SplitText) => any) | undefined;
|
|
281
299
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
282
300
|
declare const __VLS_export$2: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
|
|
283
301
|
declare const _default$1: typeof __VLS_export$2;
|
|
@@ -291,7 +309,7 @@ type __VLS_WithSlots$2<T, S> = T & {
|
|
|
291
309
|
type __VLS_Slots$1 = {
|
|
292
310
|
default(props: DejaVueAnimationScopeProps): any;
|
|
293
311
|
};
|
|
294
|
-
type __VLS_ModelProps
|
|
312
|
+
type __VLS_ModelProps = {
|
|
295
313
|
'progress'?: number;
|
|
296
314
|
};
|
|
297
315
|
declare const __VLS_base$1: import("vue").DefineComponent<(DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
@@ -303,7 +321,7 @@ declare const __VLS_base$1: import("vue").DefineComponent<(DejaVueAnimationCompo
|
|
|
303
321
|
} & {
|
|
304
322
|
duration?: number;
|
|
305
323
|
options?: gsap.TimelineVars;
|
|
306
|
-
} & __VLS_ModelProps
|
|
324
|
+
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
307
325
|
progress?: number;
|
|
308
326
|
} & {
|
|
309
327
|
trigger?: never;
|
|
@@ -312,7 +330,7 @@ declare const __VLS_base$1: import("vue").DefineComponent<(DejaVueAnimationCompo
|
|
|
312
330
|
} & {
|
|
313
331
|
duration?: number;
|
|
314
332
|
options?: gsap.TimelineVars;
|
|
315
|
-
} & __VLS_ModelProps
|
|
333
|
+
} & __VLS_ModelProps), DejaVueAnimationInstance, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
316
334
|
complete: (...args: any[]) => void;
|
|
317
335
|
interrupt: (...args: any[]) => void;
|
|
318
336
|
repeat: (...args: any[]) => void;
|
|
@@ -329,7 +347,7 @@ declare const __VLS_base$1: import("vue").DefineComponent<(DejaVueAnimationCompo
|
|
|
329
347
|
} & {
|
|
330
348
|
duration?: number;
|
|
331
349
|
options?: gsap.TimelineVars;
|
|
332
|
-
} & __VLS_ModelProps
|
|
350
|
+
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
333
351
|
progress?: number;
|
|
334
352
|
} & {
|
|
335
353
|
trigger?: never;
|
|
@@ -338,7 +356,7 @@ declare const __VLS_base$1: import("vue").DefineComponent<(DejaVueAnimationCompo
|
|
|
338
356
|
} & {
|
|
339
357
|
duration?: number;
|
|
340
358
|
options?: gsap.TimelineVars;
|
|
341
|
-
} & __VLS_ModelProps
|
|
359
|
+
} & __VLS_ModelProps)> & Readonly<{
|
|
342
360
|
"onUpdate:progress"?: ((value: number) => any) | undefined;
|
|
343
361
|
onComplete?: ((...args: any[]) => any) | undefined;
|
|
344
362
|
onInterrupt?: ((...args: any[]) => any) | undefined;
|
|
@@ -346,7 +364,11 @@ declare const __VLS_base$1: import("vue").DefineComponent<(DejaVueAnimationCompo
|
|
|
346
364
|
onReverseComplete?: ((...args: any[]) => any) | undefined;
|
|
347
365
|
onStart?: ((...args: any[]) => any) | undefined;
|
|
348
366
|
onUpdate?: ((...args: any[]) => any) | undefined;
|
|
349
|
-
}>, {
|
|
367
|
+
}>, {
|
|
368
|
+
reducedMotion: ReducedMotionMode;
|
|
369
|
+
duration: number;
|
|
370
|
+
options: gsap.TimelineVars;
|
|
371
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
350
372
|
declare const __VLS_export$1: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
351
373
|
declare const _default$2: typeof __VLS_export$1;
|
|
352
374
|
type __VLS_WithSlots$1<T, S> = T & {
|
|
@@ -359,202 +381,7 @@ type __VLS_WithSlots$1<T, S> = T & {
|
|
|
359
381
|
type __VLS_Slots = {
|
|
360
382
|
default(props: DejaVueAnimationScopeProps): any;
|
|
361
383
|
};
|
|
362
|
-
|
|
363
|
-
'progress'?: number;
|
|
364
|
-
};
|
|
365
|
-
declare const __VLS_base: import("vue").DefineComponent<(DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
366
|
-
progress?: number;
|
|
367
|
-
} & {
|
|
368
|
-
trigger?: unknown;
|
|
369
|
-
triggerAction?: TweenAction;
|
|
370
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
371
|
-
} & {
|
|
372
|
-
from: gsap.TweenVars;
|
|
373
|
-
to: gsap.TweenVars;
|
|
374
|
-
effect?: never;
|
|
375
|
-
effectOptions?: never;
|
|
376
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
377
|
-
progress?: number;
|
|
378
|
-
} & {
|
|
379
|
-
trigger?: unknown;
|
|
380
|
-
triggerAction?: TweenAction;
|
|
381
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
382
|
-
} & {
|
|
383
|
-
from: gsap.TweenVars;
|
|
384
|
-
to?: never;
|
|
385
|
-
effect?: never;
|
|
386
|
-
effectOptions?: never;
|
|
387
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
388
|
-
progress?: number;
|
|
389
|
-
} & {
|
|
390
|
-
trigger?: unknown;
|
|
391
|
-
triggerAction?: TweenAction;
|
|
392
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
393
|
-
} & {
|
|
394
|
-
from?: never;
|
|
395
|
-
to: gsap.TweenVars;
|
|
396
|
-
effect?: never;
|
|
397
|
-
effectOptions?: never;
|
|
398
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
399
|
-
progress?: number;
|
|
400
|
-
} & {
|
|
401
|
-
trigger?: unknown;
|
|
402
|
-
triggerAction?: TweenAction;
|
|
403
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
404
|
-
} & {
|
|
405
|
-
from?: never;
|
|
406
|
-
to?: never;
|
|
407
|
-
effect?: string;
|
|
408
|
-
effectOptions?: gsap.TweenVars;
|
|
409
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
410
|
-
progress?: number;
|
|
411
|
-
} & {
|
|
412
|
-
trigger?: never;
|
|
413
|
-
triggerAction?: never;
|
|
414
|
-
triggerOptions?: never;
|
|
415
|
-
} & {
|
|
416
|
-
from: gsap.TweenVars;
|
|
417
|
-
to: gsap.TweenVars;
|
|
418
|
-
effect?: never;
|
|
419
|
-
effectOptions?: never;
|
|
420
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
421
|
-
progress?: number;
|
|
422
|
-
} & {
|
|
423
|
-
trigger?: never;
|
|
424
|
-
triggerAction?: never;
|
|
425
|
-
triggerOptions?: never;
|
|
426
|
-
} & {
|
|
427
|
-
from: gsap.TweenVars;
|
|
428
|
-
to?: never;
|
|
429
|
-
effect?: never;
|
|
430
|
-
effectOptions?: never;
|
|
431
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
432
|
-
progress?: number;
|
|
433
|
-
} & {
|
|
434
|
-
trigger?: never;
|
|
435
|
-
triggerAction?: never;
|
|
436
|
-
triggerOptions?: never;
|
|
437
|
-
} & {
|
|
438
|
-
from?: never;
|
|
439
|
-
to: gsap.TweenVars;
|
|
440
|
-
effect?: never;
|
|
441
|
-
effectOptions?: never;
|
|
442
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
443
|
-
progress?: number;
|
|
444
|
-
} & {
|
|
445
|
-
trigger?: never;
|
|
446
|
-
triggerAction?: never;
|
|
447
|
-
triggerOptions?: never;
|
|
448
|
-
} & {
|
|
449
|
-
from?: never;
|
|
450
|
-
to?: never;
|
|
451
|
-
effect?: string;
|
|
452
|
-
effectOptions?: gsap.TweenVars;
|
|
453
|
-
} & __VLS_ModelProps), DejaVueAnimationInstance, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
454
|
-
complete: (...args: any[]) => void;
|
|
455
|
-
interrupt: (...args: any[]) => void;
|
|
456
|
-
repeat: (...args: any[]) => void;
|
|
457
|
-
reverseComplete: (...args: any[]) => void;
|
|
458
|
-
start: (...args: any[]) => void;
|
|
459
|
-
update: (...args: any[]) => void;
|
|
460
|
-
"update:progress": (value: number) => void;
|
|
461
|
-
}, string, import("vue").PublicProps, Readonly<(DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
462
|
-
progress?: number;
|
|
463
|
-
} & {
|
|
464
|
-
trigger?: unknown;
|
|
465
|
-
triggerAction?: TweenAction;
|
|
466
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
467
|
-
} & {
|
|
468
|
-
from: gsap.TweenVars;
|
|
469
|
-
to: gsap.TweenVars;
|
|
470
|
-
effect?: never;
|
|
471
|
-
effectOptions?: never;
|
|
472
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
473
|
-
progress?: number;
|
|
474
|
-
} & {
|
|
475
|
-
trigger?: unknown;
|
|
476
|
-
triggerAction?: TweenAction;
|
|
477
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
478
|
-
} & {
|
|
479
|
-
from: gsap.TweenVars;
|
|
480
|
-
to?: never;
|
|
481
|
-
effect?: never;
|
|
482
|
-
effectOptions?: never;
|
|
483
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
484
|
-
progress?: number;
|
|
485
|
-
} & {
|
|
486
|
-
trigger?: unknown;
|
|
487
|
-
triggerAction?: TweenAction;
|
|
488
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
489
|
-
} & {
|
|
490
|
-
from?: never;
|
|
491
|
-
to: gsap.TweenVars;
|
|
492
|
-
effect?: never;
|
|
493
|
-
effectOptions?: never;
|
|
494
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
495
|
-
progress?: number;
|
|
496
|
-
} & {
|
|
497
|
-
trigger?: unknown;
|
|
498
|
-
triggerAction?: TweenAction;
|
|
499
|
-
triggerOptions?: AnimationTriggerOptions;
|
|
500
|
-
} & {
|
|
501
|
-
from?: never;
|
|
502
|
-
to?: never;
|
|
503
|
-
effect?: string;
|
|
504
|
-
effectOptions?: gsap.TweenVars;
|
|
505
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
506
|
-
progress?: number;
|
|
507
|
-
} & {
|
|
508
|
-
trigger?: never;
|
|
509
|
-
triggerAction?: never;
|
|
510
|
-
triggerOptions?: never;
|
|
511
|
-
} & {
|
|
512
|
-
from: gsap.TweenVars;
|
|
513
|
-
to: gsap.TweenVars;
|
|
514
|
-
effect?: never;
|
|
515
|
-
effectOptions?: never;
|
|
516
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
517
|
-
progress?: number;
|
|
518
|
-
} & {
|
|
519
|
-
trigger?: never;
|
|
520
|
-
triggerAction?: never;
|
|
521
|
-
triggerOptions?: never;
|
|
522
|
-
} & {
|
|
523
|
-
from: gsap.TweenVars;
|
|
524
|
-
to?: never;
|
|
525
|
-
effect?: never;
|
|
526
|
-
effectOptions?: never;
|
|
527
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
528
|
-
progress?: number;
|
|
529
|
-
} & {
|
|
530
|
-
trigger?: never;
|
|
531
|
-
triggerAction?: never;
|
|
532
|
-
triggerOptions?: never;
|
|
533
|
-
} & {
|
|
534
|
-
from?: never;
|
|
535
|
-
to: gsap.TweenVars;
|
|
536
|
-
effect?: never;
|
|
537
|
-
effectOptions?: never;
|
|
538
|
-
} & __VLS_ModelProps) | (DejaVueAnimationComponentProps & AnimationNestableChild & {
|
|
539
|
-
progress?: number;
|
|
540
|
-
} & {
|
|
541
|
-
trigger?: never;
|
|
542
|
-
triggerAction?: never;
|
|
543
|
-
triggerOptions?: never;
|
|
544
|
-
} & {
|
|
545
|
-
from?: never;
|
|
546
|
-
to?: never;
|
|
547
|
-
effect?: string;
|
|
548
|
-
effectOptions?: gsap.TweenVars;
|
|
549
|
-
} & __VLS_ModelProps)> & Readonly<{
|
|
550
|
-
"onUpdate:progress"?: ((value: number) => any) | undefined;
|
|
551
|
-
onComplete?: ((...args: any[]) => any) | undefined;
|
|
552
|
-
onInterrupt?: ((...args: any[]) => any) | undefined;
|
|
553
|
-
onRepeat?: ((...args: any[]) => any) | undefined;
|
|
554
|
-
onReverseComplete?: ((...args: any[]) => any) | undefined;
|
|
555
|
-
onStart?: ((...args: any[]) => any) | undefined;
|
|
556
|
-
onUpdate?: ((...args: any[]) => any) | undefined;
|
|
557
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
384
|
+
declare const __VLS_base: import("vue").DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
|
|
558
385
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
559
386
|
declare const _default$3: typeof __VLS_export;
|
|
560
387
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -563,4 +390,4 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
563
390
|
};
|
|
564
391
|
};
|
|
565
392
|
//#endregion
|
|
566
|
-
export { ANIMATION_EVENTS, Animation, type AnimationChild, type AnimationComposeDefinition, AnimationControls, type AnimationDirection, type AnimationEvent, type AnimationEventEmitter, type AnimationNestableChild, AnimationNestingOptions, AnimationNestingTarget, AnimationScopeOptions, type AnimationTriggerOptions, type ControllableAnimation, type DejaVueAnimationComponentProps, type DejaVueAnimationExposed, type DejaVueAnimationInstance, type DejaVueAnimationParent, type DejaVueAnimationScopeProps, type DejaVueComponent, type DejaVueMarkerExposed, type DejaVueMarkerInstance, type DejaVueMarkerScopeProps, type DejaVueNode, type DejaVueSplitTextExposed, type DejaVueSplitTextInstance, type DejaVueSplitTextScopeProps, _default as Marker, type NonEmptyArray, type PlainObject, _default$1 as SplitText, SplitTextOptions, _default$2 as Timeline, _default$3 as Tween, type TweenAction, type TweenDefinition, type WrappableComponent, applyTimelineTotalDuration, cloneObject, dejaVueParentInstance, getScrollTriggerToggleActionByEvent, isEmptyTarget, isObject, patchArray, patchObject, resolveChildrenTweenTarget, resolveTimelinePosition, stripScrollTriggerVars, syncData, toNonEmptyArray, useAnimationControls, useAnimationNesting, useAnimationScope, useSplitText, useStableObjectProp, useTweenVars };
|
|
393
|
+
export { ANIMATION_EVENTS, Animation, type AnimationChild, type AnimationComposeDefinition, type AnimationComposeTween, AnimationControls, type AnimationDirection, type AnimationEvent, type AnimationEventEmitter, type AnimationNestableChild, AnimationNestingOptions, AnimationNestingTarget, AnimationOptions, AnimationScopeOptions, type AnimationTriggerOptions, type ControllableAnimation, type DejaVueAnimationComponentProps, type DejaVueAnimationExposed, type DejaVueAnimationInstance, type DejaVueAnimationParent, type DejaVueAnimationScopeProps, type DejaVueComponent, type DejaVueMarkerExposed, type DejaVueMarkerInstance, type DejaVueMarkerScopeProps, type DejaVueNode, type DejaVueSplitTextExposed, type DejaVueSplitTextInstance, type DejaVueSplitTextScopeProps, _default as Marker, type NonEmptyArray, type PlainObject, ReducedMotionMode, _default$1 as SplitText, SplitTextOptions, _default$2 as Timeline, _default$3 as Tween, type TweenAction, type TweenDefinition, type WrappableComponent, applyTimelineTotalDuration, cloneObject, dejaVueParentInstance, getReducedMotionTween, getScrollTriggerToggleActionByEvent, isEmptyTarget, isObject, patchArray, patchObject, resolveChildrenTweenTarget, resolveTimelinePosition, stripScrollTriggerVars, syncData, toNonEmptyArray, useAnimationControls, useAnimationNesting, useAnimationScope, useReducedMotion, useSplitText, useStableObjectProp, useTweenVars };
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,20 @@ function applyTimelineTotalDuration(timeline) {
|
|
|
54
54
|
const totalDuration = "totalDuration" in (timeline.data || {}) ? timeline.data.totalDuration : void 0;
|
|
55
55
|
if (totalDuration) timeline.duration(totalDuration);
|
|
56
56
|
}
|
|
57
|
+
function getReducedMotionTween({ method, vars }) {
|
|
58
|
+
if (method === "from") return;
|
|
59
|
+
if (method === "fromTo") {
|
|
60
|
+
const [_, to] = vars;
|
|
61
|
+
return {
|
|
62
|
+
method: "set",
|
|
63
|
+
vars: to
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
method: "set",
|
|
68
|
+
vars
|
|
69
|
+
};
|
|
70
|
+
}
|
|
57
71
|
function getScrollTriggerToggleActionByEvent(event, instance) {
|
|
58
72
|
if (!instance?.vars.toggleActions) return;
|
|
59
73
|
const actions = instance.vars.toggleActions.split(" ");
|
|
@@ -129,11 +143,14 @@ if (typeof window !== "undefined") gsap.registerPlugin(ScrollTrigger);
|
|
|
129
143
|
var Animation = class extends EventBus {
|
|
130
144
|
ctx;
|
|
131
145
|
scrollTrigger;
|
|
146
|
+
reducedMotion;
|
|
132
147
|
timeline;
|
|
133
148
|
constructor(options) {
|
|
134
149
|
super(ANIMATION_EVENTS);
|
|
150
|
+
const { reducedMotion, ...timelineOptions } = options ?? {};
|
|
151
|
+
this.reducedMotion = !!reducedMotion;
|
|
135
152
|
this.timeline = gsap.timeline({
|
|
136
|
-
...
|
|
153
|
+
...timelineOptions,
|
|
137
154
|
onComplete: () => this.dispatch("complete", this),
|
|
138
155
|
onInterrupt: () => this.dispatch("interrupt", this),
|
|
139
156
|
onRepeat: () => this.dispatch("repeat", this),
|
|
@@ -149,7 +166,7 @@ var Animation = class extends EventBus {
|
|
|
149
166
|
}
|
|
150
167
|
attachScrollTrigger(vars) {
|
|
151
168
|
this.scrollTrigger?.kill();
|
|
152
|
-
if (!vars) return;
|
|
169
|
+
if (!vars || this.reducedMotion) return;
|
|
153
170
|
this.scrollTrigger = ScrollTrigger.create({
|
|
154
171
|
...vars,
|
|
155
172
|
animation: this.timeline,
|
|
@@ -177,6 +194,12 @@ var Animation = class extends EventBus {
|
|
|
177
194
|
this.ctx = gsap.context(() => this.compose(definition, false));
|
|
178
195
|
return;
|
|
179
196
|
}
|
|
197
|
+
if (this.reducedMotion) {
|
|
198
|
+
this.attachScrollTrigger(null);
|
|
199
|
+
const { method, vars } = getReducedMotionTween(definition) || {};
|
|
200
|
+
if (method && vars) this.timeline[method](definition.target, vars);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
180
203
|
let scrollTriggerVars = null;
|
|
181
204
|
if (definition.method === "fromTo") {
|
|
182
205
|
const [from, to] = definition.vars;
|
|
@@ -383,6 +406,22 @@ function useAnimationScope(options) {
|
|
|
383
406
|
};
|
|
384
407
|
}
|
|
385
408
|
//#endregion
|
|
409
|
+
//#region src/composables/useReducedMotion.ts
|
|
410
|
+
const systemReducedMotion = ref(false);
|
|
411
|
+
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
412
|
+
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
413
|
+
systemReducedMotion.value = mediaQuery.matches;
|
|
414
|
+
mediaQuery.addEventListener("change", (e) => systemReducedMotion.value = e.matches);
|
|
415
|
+
}
|
|
416
|
+
function useReducedMotion(mode) {
|
|
417
|
+
const parent = inject(dejaVueParentInstance, null);
|
|
418
|
+
const reducedMotionMode = computed(() => toValue(mode) ?? unref(parent?.reducedMotion) ?? "auto");
|
|
419
|
+
return {
|
|
420
|
+
computed: computed(() => reducedMotionMode.value === "auto" ? systemReducedMotion.value : reducedMotionMode.value),
|
|
421
|
+
system: systemReducedMotion
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
386
425
|
//#region src/composables/useSplitText.ts
|
|
387
426
|
if (typeof window !== "undefined") gsap.registerPlugin(SplitText);
|
|
388
427
|
function useSplitText(domTarget, options) {
|
|
@@ -623,6 +662,11 @@ var SplitText_default = /* @__PURE__ */ defineComponent({
|
|
|
623
662
|
var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
624
663
|
__name: "Timeline",
|
|
625
664
|
props: /*@__PURE__*/ mergeModels({
|
|
665
|
+
reducedMotion: {
|
|
666
|
+
type: [Boolean, String],
|
|
667
|
+
required: false,
|
|
668
|
+
default: void 0
|
|
669
|
+
},
|
|
626
670
|
revertOnDispose: {
|
|
627
671
|
type: Boolean,
|
|
628
672
|
required: false
|
|
@@ -661,11 +705,13 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
661
705
|
},
|
|
662
706
|
duration: {
|
|
663
707
|
type: Number,
|
|
664
|
-
required: false
|
|
708
|
+
required: false,
|
|
709
|
+
default: -Infinity
|
|
665
710
|
},
|
|
666
711
|
options: {
|
|
667
712
|
type: null,
|
|
668
|
-
required: false
|
|
713
|
+
required: false,
|
|
714
|
+
default: () => ({})
|
|
669
715
|
}
|
|
670
716
|
}, {
|
|
671
717
|
"progress": {
|
|
@@ -680,6 +726,7 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
680
726
|
const emit = __emit;
|
|
681
727
|
const { AnimationScope, root, tweenTarget } = useAnimationScope({ tweenTarget: () => props.tweenTarget });
|
|
682
728
|
const options = useStableObjectProp(() => props.options);
|
|
729
|
+
const { computed: reducedMotion } = useReducedMotion(() => props.reducedMotion);
|
|
683
730
|
const vars = computed(() => {
|
|
684
731
|
const tl = cloneObject(options);
|
|
685
732
|
return {
|
|
@@ -692,7 +739,8 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
692
739
|
data: typeof props.duration === "number" && props.duration > 0 ? {
|
|
693
740
|
...vars.value?.timeline.data,
|
|
694
741
|
totalDuration: props.duration
|
|
695
|
-
} : vars.value?.timeline.data
|
|
742
|
+
} : vars.value?.timeline.data,
|
|
743
|
+
reducedMotion: reducedMotion.value
|
|
696
744
|
});
|
|
697
745
|
const progress = useModel(__props, "progress");
|
|
698
746
|
const { controlled, direction } = useAnimationControls(animation, {
|
|
@@ -713,6 +761,7 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
713
761
|
direction,
|
|
714
762
|
parent,
|
|
715
763
|
progress,
|
|
764
|
+
reducedMotion,
|
|
716
765
|
seamless: computed(() => props.seamless),
|
|
717
766
|
tweenTarget
|
|
718
767
|
};
|
|
@@ -721,11 +770,14 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
721
770
|
Object.assign(animation.timeline.vars, cloneObject(vars));
|
|
722
771
|
animation.timeline.invalidate();
|
|
723
772
|
});
|
|
724
|
-
watch(() => vars.value.scrollTrigger, async (
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
animation.attachScrollTrigger(
|
|
728
|
-
|
|
773
|
+
watch([reducedMotion, () => vars.value.scrollTrigger], async ([hasReducedMotion, scrollTrigger]) => {
|
|
774
|
+
animation.reducedMotion = hasReducedMotion;
|
|
775
|
+
if (animation.reducedMotion || !scrollTrigger || !Object.keys(scrollTrigger).length) {
|
|
776
|
+
animation.attachScrollTrigger(null);
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
await nextTick();
|
|
780
|
+
animation.attachScrollTrigger(scrollTrigger);
|
|
729
781
|
}, { immediate: true });
|
|
730
782
|
watch(() => props.duration, (duration) => {
|
|
731
783
|
if (typeof duration === "number" && duration > 0) {
|
|
@@ -744,12 +796,14 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
744
796
|
animation: unref(animation),
|
|
745
797
|
direction: unref(direction),
|
|
746
798
|
parent: unref(parent),
|
|
747
|
-
progress: progress.value
|
|
799
|
+
progress: progress.value,
|
|
800
|
+
"reduced-motion": unref(reducedMotion)
|
|
748
801
|
}, null, 8, [
|
|
749
802
|
"animation",
|
|
750
803
|
"direction",
|
|
751
804
|
"parent",
|
|
752
|
-
"progress"
|
|
805
|
+
"progress",
|
|
806
|
+
"reduced-motion"
|
|
753
807
|
]);
|
|
754
808
|
};
|
|
755
809
|
}
|
|
@@ -759,6 +813,11 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
759
813
|
var Tween_default = /* @__PURE__ */ defineComponent({
|
|
760
814
|
__name: "Tween",
|
|
761
815
|
props: /*@__PURE__*/ mergeModels({
|
|
816
|
+
reducedMotion: {
|
|
817
|
+
type: [Boolean, String],
|
|
818
|
+
required: false,
|
|
819
|
+
default: void 0
|
|
820
|
+
},
|
|
762
821
|
revertOnDispose: {
|
|
763
822
|
type: Boolean,
|
|
764
823
|
required: false
|
|
@@ -823,7 +882,8 @@ var Tween_default = /* @__PURE__ */ defineComponent({
|
|
|
823
882
|
const props = __props;
|
|
824
883
|
const emit = __emit;
|
|
825
884
|
const { AnimationScope, root, tweenTarget } = useAnimationScope({ tweenTarget: () => props.tweenTarget });
|
|
826
|
-
const
|
|
885
|
+
const { computed: reducedMotion } = useReducedMotion(() => props.reducedMotion);
|
|
886
|
+
const animation = new Animation({ reducedMotion: reducedMotion.value });
|
|
827
887
|
const progress = useModel(__props, "progress");
|
|
828
888
|
const { controlled, direction } = useAnimationControls(animation, {
|
|
829
889
|
progress,
|
|
@@ -844,6 +904,7 @@ var Tween_default = /* @__PURE__ */ defineComponent({
|
|
|
844
904
|
direction,
|
|
845
905
|
parent,
|
|
846
906
|
progress,
|
|
907
|
+
reducedMotion,
|
|
847
908
|
seamless: computed(() => props.seamless),
|
|
848
909
|
tweenTarget
|
|
849
910
|
};
|
|
@@ -852,8 +913,10 @@ var Tween_default = /* @__PURE__ */ defineComponent({
|
|
|
852
913
|
root,
|
|
853
914
|
tweenMethod,
|
|
854
915
|
tweenTarget,
|
|
855
|
-
tweenVars
|
|
856
|
-
|
|
916
|
+
tweenVars,
|
|
917
|
+
reducedMotion
|
|
918
|
+
], ([scope, method, target, vars, hasReducedMotion]) => {
|
|
919
|
+
animation.reducedMotion = hasReducedMotion;
|
|
857
920
|
if (isEmptyTarget(target) || !method) return;
|
|
858
921
|
animation.clear(props.revertOnDispose);
|
|
859
922
|
const definition = {
|
|
@@ -873,15 +936,17 @@ var Tween_default = /* @__PURE__ */ defineComponent({
|
|
|
873
936
|
animation: unref(animation),
|
|
874
937
|
direction: unref(direction),
|
|
875
938
|
parent: unref(parent),
|
|
876
|
-
progress: progress.value
|
|
939
|
+
progress: progress.value,
|
|
940
|
+
"reduced-motion": unref(reducedMotion)
|
|
877
941
|
}, null, 8, [
|
|
878
942
|
"animation",
|
|
879
943
|
"direction",
|
|
880
944
|
"parent",
|
|
881
|
-
"progress"
|
|
945
|
+
"progress",
|
|
946
|
+
"reduced-motion"
|
|
882
947
|
]);
|
|
883
948
|
};
|
|
884
949
|
}
|
|
885
950
|
});
|
|
886
951
|
//#endregion
|
|
887
|
-
export { ANIMATION_EVENTS, Animation, Marker_default as Marker, SplitText_default as SplitText, Timeline_default as Timeline, Tween_default as Tween, applyTimelineTotalDuration, cloneObject, dejaVueParentInstance, getScrollTriggerToggleActionByEvent, isEmptyTarget, isObject, patchArray, patchObject, resolveChildrenTweenTarget, resolveTimelinePosition, stripScrollTriggerVars, syncData, toNonEmptyArray, useAnimationControls, useAnimationNesting, useAnimationScope, useSplitText, useStableObjectProp, useTweenVars };
|
|
952
|
+
export { ANIMATION_EVENTS, Animation, Marker_default as Marker, SplitText_default as SplitText, Timeline_default as Timeline, Tween_default as Tween, applyTimelineTotalDuration, cloneObject, dejaVueParentInstance, getReducedMotionTween, getScrollTriggerToggleActionByEvent, isEmptyTarget, isObject, patchArray, patchObject, resolveChildrenTweenTarget, resolveTimelinePosition, stripScrollTriggerVars, syncData, toNonEmptyArray, useAnimationControls, useAnimationNesting, useAnimationScope, useReducedMotion, useSplitText, useStableObjectProp, useTweenVars };
|