deja-vue 2.0.1 → 2.1.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 CHANGED
@@ -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;
@@ -271,11 +273,11 @@ type __VLS_Slots$2 = {
271
273
  default(props: DejaVueSplitTextScopeProps): any;
272
274
  };
273
275
  declare const __VLS_base$2: import("vue").DefineComponent<__VLS_Props, DejaVueSplitTextInstance, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
274
- revert: (splitText: SplitText) => any;
275
276
  split: (splitText: SplitText) => any;
277
+ revert: (splitText: SplitText) => any;
276
278
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
277
- onRevert?: ((splitText: SplitText) => any) | undefined;
278
279
  onSplit?: ((splitText: SplitText) => any) | undefined;
280
+ onRevert?: ((splitText: SplitText) => any) | undefined;
279
281
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
280
282
  declare const __VLS_export$2: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
281
283
  declare const _default$1: typeof __VLS_export$2;
package/dist/index.js CHANGED
@@ -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(true);
858
+ animation.clear(props.revertOnDispose);
846
859
  const definition = {
847
860
  method,
848
861
  scope,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "deja-vue",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.1.0",
5
5
  "description": "Declarative GSAP Animations for Vue 3",
6
6
  "author": "Andrea 'Fiad' Fiadone <hello@fiad.one>",
7
7
  "license": "MIT",