deja-vue 2.0.1 → 2.1.1
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 +4 -2
- package/dist/index.js +22 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, ComputedRef, InjectionKey, MaybeRef, MaybeRefOrGetter, ModelRef, Reactive, Ref, ShallowRef, ShallowUnwrapRef, WatchOptions } from "vue";
|
|
2
2
|
import { NodeRef } from "vue-unwrap";
|
|
3
|
-
import
|
|
3
|
+
import SplitText from "gsap/SplitText";
|
|
4
4
|
|
|
5
5
|
//#region src/core/EventBus.d.ts
|
|
6
6
|
declare class EventBus<E extends string, A extends unknown[] = []> {
|
|
@@ -26,7 +26,7 @@ declare class Animation extends EventBus<AnimationEvent, [animation: Animation]>
|
|
|
26
26
|
getChildPosition(child: AnimationChild): number | undefined;
|
|
27
27
|
run(action?: TweenAction, ...args: any[]): void;
|
|
28
28
|
clear(revert?: boolean): void;
|
|
29
|
-
dispose(): void;
|
|
29
|
+
dispose(revert?: boolean): void;
|
|
30
30
|
private handleScrollTriggerReset;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
@@ -47,6 +47,7 @@ interface DejaVueAnimationInstance extends DejaVueComponent {
|
|
|
47
47
|
progress: ModelRef<ControllableAnimation['progress']>;
|
|
48
48
|
}
|
|
49
49
|
interface DejaVueAnimationComponentProps {
|
|
50
|
+
revertOnDispose?: boolean;
|
|
50
51
|
seamless?: boolean;
|
|
51
52
|
tweenTarget?: 'children' | 'self' | gsap.TweenTarget;
|
|
52
53
|
}
|
|
@@ -166,6 +167,7 @@ declare function useAnimationControls(animation: Animation, controls: AnimationC
|
|
|
166
167
|
interface AnimationNestingOptions {
|
|
167
168
|
parent?: DejaVueAnimationParent | null;
|
|
168
169
|
position?: MaybeRefOrGetter<gsap.Position | undefined>;
|
|
170
|
+
revertOnDispose?: MaybeRefOrGetter<boolean>;
|
|
169
171
|
}
|
|
170
172
|
type AnimationNestingTarget = ({
|
|
171
173
|
animation: Animation;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { gsap } from "gsap";
|
|
2
|
-
import
|
|
2
|
+
import ScrollTrigger from "gsap/ScrollTrigger";
|
|
3
3
|
import { computed, createBlock, defineComponent, effectScope, inject, mergeModels, nextTick, onUnmounted, openBlock, provide, reactive, ref, renderSlot, shallowReactive, shallowRef, toRefs, toValue, unref, useAttrs, useModel, watch } from "vue";
|
|
4
4
|
import { getNodeElement, useUnwrap } from "vue-unwrap";
|
|
5
|
-
import
|
|
5
|
+
import SplitText from "gsap/SplitText";
|
|
6
6
|
//#region src/constants.ts
|
|
7
7
|
const ANIMATION_EVENTS = [
|
|
8
8
|
"complete",
|
|
@@ -232,11 +232,13 @@ var Animation = class extends EventBus {
|
|
|
232
232
|
}
|
|
233
233
|
clear(revert) {
|
|
234
234
|
if (revert) this.ctx?.revert();
|
|
235
|
+
else this.ctx?.kill();
|
|
235
236
|
this.timeline?.clear(true);
|
|
236
237
|
}
|
|
237
|
-
dispose() {
|
|
238
|
+
dispose(revert) {
|
|
238
239
|
super.dispose();
|
|
239
|
-
this.ctx?.revert();
|
|
240
|
+
if (revert) this.ctx?.revert();
|
|
241
|
+
else this.ctx?.kill();
|
|
240
242
|
this.scrollTrigger?.kill();
|
|
241
243
|
this.timeline?.kill();
|
|
242
244
|
this.ctx = null;
|
|
@@ -312,6 +314,7 @@ function useAnimationControls(animation, controls) {
|
|
|
312
314
|
function useAnimationNesting(target, options) {
|
|
313
315
|
const parent = options?.parent === null ? null : options?.parent || inject(dejaVueParentInstance, null);
|
|
314
316
|
const position = computed(() => toValue(options?.position));
|
|
317
|
+
const revertOnDispose = computed(() => toValue(options?.revertOnDispose));
|
|
315
318
|
const children = computed(() => toNonEmptyArray([target].flat().map((child) => {
|
|
316
319
|
if (!child) return "";
|
|
317
320
|
if ("animation" in child) return child.animation;
|
|
@@ -341,9 +344,9 @@ function useAnimationNesting(target, options) {
|
|
|
341
344
|
if (!children.value) return;
|
|
342
345
|
if (parent) children.value.forEach((child) => {
|
|
343
346
|
parent.animation.remove(child, true);
|
|
344
|
-
if (child instanceof Animation) child.dispose();
|
|
347
|
+
if (child instanceof Animation) child.dispose(revertOnDispose.value);
|
|
345
348
|
});
|
|
346
|
-
else children.value.forEach((child) => child instanceof Animation && child.dispose());
|
|
349
|
+
else children.value.forEach((child) => child instanceof Animation && child.dispose(revertOnDispose.value));
|
|
347
350
|
});
|
|
348
351
|
return { parent };
|
|
349
352
|
}
|
|
@@ -620,6 +623,10 @@ var SplitText_default = /* @__PURE__ */ defineComponent({
|
|
|
620
623
|
var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
621
624
|
__name: "Timeline",
|
|
622
625
|
props: /*@__PURE__*/ mergeModels({
|
|
626
|
+
revertOnDispose: {
|
|
627
|
+
type: Boolean,
|
|
628
|
+
required: false
|
|
629
|
+
},
|
|
623
630
|
seamless: {
|
|
624
631
|
type: Boolean,
|
|
625
632
|
required: false
|
|
@@ -696,7 +703,8 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
696
703
|
});
|
|
697
704
|
const { parent } = useAnimationNesting({ animation }, {
|
|
698
705
|
parent: props.parent,
|
|
699
|
-
position: () => props.position
|
|
706
|
+
position: () => props.position,
|
|
707
|
+
revertOnDispose: () => props.revertOnDispose
|
|
700
708
|
});
|
|
701
709
|
const instance = {
|
|
702
710
|
$el: root,
|
|
@@ -751,6 +759,10 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
751
759
|
var Tween_default = /* @__PURE__ */ defineComponent({
|
|
752
760
|
__name: "Tween",
|
|
753
761
|
props: /*@__PURE__*/ mergeModels({
|
|
762
|
+
revertOnDispose: {
|
|
763
|
+
type: Boolean,
|
|
764
|
+
required: false
|
|
765
|
+
},
|
|
754
766
|
seamless: {
|
|
755
767
|
type: Boolean,
|
|
756
768
|
required: false
|
|
@@ -821,7 +833,8 @@ var Tween_default = /* @__PURE__ */ defineComponent({
|
|
|
821
833
|
});
|
|
822
834
|
const { parent } = useAnimationNesting({ animation }, {
|
|
823
835
|
parent: props.parent,
|
|
824
|
-
position: () => props.position
|
|
836
|
+
position: () => props.position,
|
|
837
|
+
revertOnDispose: () => props.revertOnDispose
|
|
825
838
|
});
|
|
826
839
|
const { method: tweenMethod, vars: tweenVars } = useTweenVars(props);
|
|
827
840
|
const instance = {
|
|
@@ -842,7 +855,7 @@ var Tween_default = /* @__PURE__ */ defineComponent({
|
|
|
842
855
|
tweenVars
|
|
843
856
|
], ([scope, method, target, vars]) => {
|
|
844
857
|
if (isEmptyTarget(target) || !method) return;
|
|
845
|
-
animation.clear(
|
|
858
|
+
animation.clear(props.revertOnDispose);
|
|
846
859
|
const definition = {
|
|
847
860
|
method,
|
|
848
861
|
scope,
|