animejs 4.1.2 → 4.1.3

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/types/index.d.ts CHANGED
@@ -216,11 +216,14 @@ declare function createMotionPath(path: TargetsParam): {
216
216
  };
217
217
  declare function createDrawable(selector: TargetsParam, start?: number, end?: number): Array<DrawableSVGGeometry>;
218
218
  declare function stagger(val: number | string | [
219
- number | string,
220
- number | string
221
- ], params?: StaggerParams): StaggerFunction;
219
+ number,
220
+ number
221
+ ] | [
222
+ string,
223
+ string
224
+ ], params?: StaggerParams): StaggerFunction<number | string>;
222
225
  declare namespace eases {
223
- export let linear: (...args?: (string | number)[]) => EasingFunction;
226
+ export let linear: (...args: (string | number)[]) => EasingFunction;
224
227
  export let irregular: (length?: number, randomness?: number) => EasingFunction;
225
228
  export let steps: (steps?: number, fromStart?: boolean) => EasingFunction;
226
229
  export let cubicBezier: (mX1?: number, mY1?: number, mX2?: number, mY2?: number) => EasingFunction;
@@ -304,18 +307,19 @@ declare class Animatable {
304
307
  constructor(targets: TargetsParam, parameters: AnimatableParams);
305
308
  targets: (HTMLElement | SVGElement | JSTarget)[];
306
309
  animations: {};
310
+ callbacks: JSAnimation | null;
307
311
  revert(): this;
308
312
  }
309
313
  declare function createAnimatable(targets: TargetsParam, parameters: AnimatableParams): AnimatableObject;
310
- type Revertible = Animatable | Tickable | Draggable | ScrollObserver | TextSplitter | Scope;
311
- type StaggerFunction = (target?: Target, index?: number, length?: number, tl?: Timeline) => number | string;
314
+ type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope;
315
+ type StaggerFunction<T> = (target?: Target, index?: number, length?: number, tl?: Timeline) => T;
312
316
  type StaggerParams = {
313
317
  start?: number | string;
314
318
  from?: number | 'first' | 'center' | 'last' | 'random';
315
319
  reversed?: boolean;
316
320
  grid?: Array<number>;
317
321
  axis?: ('x' | 'y');
318
- use?: string | StaggerFunction;
322
+ use?: string | ((target: Target, i: number, length: number) => number);
319
323
  total?: number;
320
324
  ease?: EasingParam;
321
325
  modifier?: TweenModifier;
@@ -334,6 +338,24 @@ type JSTargetsParam = Array<JSTarget> | JSTarget;
334
338
  type JSTargetsArray = Array<JSTarget>;
335
339
  type TargetsParam = Array<TargetSelector> | TargetSelector;
336
340
  type TargetsArray = Array<Target>;
341
+ type SpringParams = {
342
+ /**
343
+ * - Mass, default 1
344
+ */
345
+ mass?: number;
346
+ /**
347
+ * - Stiffness, default 100
348
+ */
349
+ stiffness?: number;
350
+ /**
351
+ * - Damping, default 10
352
+ */
353
+ damping?: number;
354
+ /**
355
+ * - Initial velocity, default 0
356
+ */
357
+ velocity?: number;
358
+ };
337
359
  type Callback<T> = (self: T, e?: PointerEvent) => any;
338
360
  type TickableCallbacks<T extends unknown> = {
339
361
  onBegin?: Callback<T>;
@@ -469,11 +491,61 @@ type AnimationOptions = {
469
491
  playbackEase?: EasingParam;
470
492
  };
471
493
  type AnimationParams = Record<string, TweenOptions | Callback<JSAnimation> | TweenModifier | boolean | PercentageKeyframes | (Record<string, boolean | TweenModifier | TweenOptions> & TweenParamsOptions)[] | ScrollObserver> & TimerOptions & AnimationOptions & TweenParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>;
494
+ /**
495
+ * Accepts:<br>
496
+ * - `Number` - Absolute position in milliseconds (e.g., `500` places element at exactly 500ms)<br>
497
+ * - `'+=Number'` - Addition: Position element X ms after the last element (e.g., `'+=100'`)<br>
498
+ * - `'-=Number'` - Subtraction: Position element X ms before the last element's end (e.g., `'-=100'`)<br>
499
+ * - `'*=Number'` - Multiplier: Position element at a fraction of the total duration (e.g., `'*=.5'` for halfway)<br>
500
+ * - `'<'` - Previous end: Position element at the end position of the previous element<br>
501
+ * - `'<<'` - Previous start: Position element at the start position of the previous element<br>
502
+ * - `'<<+=Number'` - Combined: Position element relative to previous element's start (e.g., `'<<+=250'`)<br>
503
+ * - `'label'` - Label: Position element at a named label position (e.g., `'My Label'`)
504
+ */
505
+ type TimelinePosition = number | `+=${number}` | `-=${number}` | `*=${number}` | '<' | '<<' | `<<+=${number}` | `<<-=${number}` | string;
506
+ /**
507
+ * Accepts:<br>
508
+ * - `Number` - Absolute position in milliseconds (e.g., `500` places animation at exactly 500ms)<br>
509
+ * - `'+=Number'` - Addition: Position animation X ms after the last animation (e.g., `'+=100'`)<br>
510
+ * - `'-=Number'` - Subtraction: Position animation X ms before the last animation's end (e.g., `'-=100'`)<br>
511
+ * - `'*=Number'` - Multiplier: Position animation at a fraction of the total duration (e.g., `'*=.5'` for halfway)<br>
512
+ * - `'<'` - Previous end: Position animation at the end position of the previous animation<br>
513
+ * - `'<<'` - Previous start: Position animation at the start position of the previous animation<br>
514
+ * - `'<<+=Number'` - Combined: Position animation relative to previous animation's start (e.g., `'<<+=250'`)<br>
515
+ * - `'label'` - Label: Position animation at a named label position (e.g., `'My Label'`)<br>
516
+ * - `stagger(String|Nummber)` - Stagger multi-elements animation positions (e.g., 10, 20, 30...)
517
+ */
518
+ type TimelineAnimationPosition = TimelinePosition | StaggerFunction<number | string>;
472
519
  type TimelineOptions = {
473
520
  defaults?: DefaultsParams;
474
521
  playbackEase?: EasingParam;
475
522
  };
476
523
  type TimelineParams = TimerOptions & TimelineOptions & TickableCallbacks<Timeline> & RenderableCallbacks<Timeline>;
524
+ type WAAPITweenValue = string | number | Array<string> | Array<number>;
525
+ type WAAPIFunctionValue = (target: DOMTarget, index: number, length: number) => WAAPITweenValue;
526
+ type WAAPIKeyframeValue = WAAPITweenValue | WAAPIFunctionValue | Array<string | number | WAAPIFunctionValue>;
527
+ type WAAPICallback = (animation: WAAPIAnimation) => void;
528
+ type WAAPITweenOptions = {
529
+ to?: WAAPIKeyframeValue;
530
+ from?: WAAPIKeyframeValue;
531
+ duration?: number | WAAPIFunctionValue;
532
+ delay?: number | WAAPIFunctionValue;
533
+ ease?: EasingParam;
534
+ composition?: CompositeOperation;
535
+ };
536
+ type WAAPIAnimationOptions = {
537
+ loop?: number | boolean;
538
+ Reversed?: boolean;
539
+ Alternate?: boolean;
540
+ autoplay?: boolean | ScrollObserver;
541
+ playbackRate?: number;
542
+ duration?: number | WAAPIFunctionValue;
543
+ delay?: number | WAAPIFunctionValue;
544
+ ease?: EasingParam;
545
+ composition?: CompositeOperation;
546
+ onComplete?: WAAPICallback;
547
+ };
548
+ type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions;
477
549
  type AnimatablePropertySetter = (to: number | Array<number>, duration?: number, ease?: EasingParam) => AnimatableObject;
478
550
  type AnimatablePropertyGetter = () => number | Array<number>;
479
551
  type AnimatableProperty = AnimatablePropertySetter & AnimatablePropertyGetter;
@@ -501,6 +573,32 @@ type ScopedCallback<T> = (scope: Scope) => T;
501
573
  type ScopeCleanupCallback = (scope?: Scope) => any;
502
574
  type ScopeConstructorCallback = (scope?: Scope) => ScopeCleanupCallback | void;
503
575
  type ScopeMethod = (...args: any[]) => ScopeCleanupCallback | void;
576
+ type ScrollThresholdValue = string | number;
577
+ type ScrollThresholdParam = {
578
+ target?: ScrollThresholdValue;
579
+ container?: ScrollThresholdValue;
580
+ };
581
+ type ScrollObserverAxisCallback = (self: ScrollObserver) => 'x' | 'y';
582
+ type ScrollThresholdCallback = (self: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam;
583
+ type ScrollObserverParams = {
584
+ id?: number | string;
585
+ sync?: boolean | number | string | EasingParam;
586
+ container?: TargetsParam;
587
+ target?: TargetsParam;
588
+ axis?: "x" | "y" | ScrollObserverAxisCallback | ((observer: ScrollObserver) => 'x' | 'y' | ScrollObserverAxisCallback);
589
+ enter?: ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback | ((observer: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback);
590
+ leave?: ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback | ((observer: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback);
591
+ repeat?: boolean | ((observer: ScrollObserver) => boolean);
592
+ debug?: boolean;
593
+ onEnter?: Callback<ScrollObserver>;
594
+ onLeave?: Callback<ScrollObserver>;
595
+ onEnterForward?: Callback<ScrollObserver>;
596
+ onLeaveForward?: Callback<ScrollObserver>;
597
+ onEnterBackward?: Callback<ScrollObserver>;
598
+ onLeaveBackward?: Callback<ScrollObserver>;
599
+ onUpdate?: Callback<ScrollObserver>;
600
+ onSyncComplete?: Callback<ScrollObserver>;
601
+ };
504
602
  type DraggableAxisParam = {
505
603
  mapTo?: string;
506
604
  modifier?: TweenModifier;
@@ -566,14 +664,14 @@ declare class Timeline extends Timer {
566
664
  defaults: DefaultsParams;
567
665
  onRender: Callback<this>;
568
666
  _ease: EasingFunction;
569
- add(a1: TargetsParam, a2: AnimationParams, a3?: TimePosition): this;
570
- add(a1: TimerParams, a2?: TimePosition): this;
571
- sync(synced?: Tickable, position?: TimePosition): this;
572
- sync(synced?: globalThis.Animation, position?: TimePosition): this;
573
- sync(synced?: WAAPIAnimation, position?: TimePosition): this;
574
- set(targets: TargetsParam, parameters: AnimationParams, position?: TimePosition): this;
575
- call(callback: Callback<Timer>, position?: TimePosition): this;
576
- label(labelName: string, position?: TimePosition): this;
667
+ add(a1: TargetsParam, a2: AnimationParams, a3?: TimelinePosition | StaggerFunction<number | string>): this;
668
+ add(a1: TimerParams, a2?: TimelinePosition): this;
669
+ sync(synced?: Tickable, position?: TimelinePosition): this;
670
+ sync(synced?: globalThis.Animation, position?: TimelinePosition): this;
671
+ sync(synced?: WAAPIAnimation, position?: TimelinePosition): this;
672
+ set(targets: TargetsParam, parameters: AnimationParams, position?: TimelinePosition): this;
673
+ call(callback: Callback<Timer>, position?: TimelinePosition): this;
674
+ label(labelName: string, position?: TimelinePosition): this;
577
675
  remove(targets: TargetsParam, propertyName?: string): this;
578
676
  stretch(newDuration: number): this;
579
677
  refresh(): this;
@@ -581,7 +679,6 @@ declare class Timeline extends Timer {
581
679
  then(callback?: Callback<this>): Promise<any>;
582
680
  }
583
681
  declare function createTimeline(parameters?: TimelineParams): Timeline;
584
- type TimePosition = number | string | Function;
585
682
  declare class Draggable {
586
683
  constructor(target: TargetsParam, parameters?: DraggableParams);
587
684
  containerArray: number[];
@@ -707,11 +804,10 @@ declare class Draggable {
707
804
  x: number;
708
805
  y: number;
709
806
  };
710
- overshootXTicker: Timer;
711
- overshootYTicker: Timer;
712
- updateTicker: Timer;
807
+ overshootTicker: Timer;
713
808
  updated: boolean;
714
809
  manual: boolean;
810
+ updateTicker: Timer;
715
811
  contained: boolean;
716
812
  grabbed: boolean;
717
813
  dragged: boolean;
@@ -882,32 +978,6 @@ declare class ScrollObserver {
882
978
  revert(): this;
883
979
  }
884
980
  declare function onScroll(parameters?: ScrollObserverParams): ScrollObserver;
885
- type ScrollThresholdValue = string | number;
886
- type ScrollThresholdParam = {
887
- target?: ScrollThresholdValue;
888
- container?: ScrollThresholdValue;
889
- };
890
- type ScrollObserverAxisCallback = (self: ScrollObserver) => "x" | "y";
891
- type ScrollThresholdCallback = (self: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam;
892
- type ScrollObserverParams = {
893
- id?: number | string;
894
- sync?: boolean | number | string | EasingParam;
895
- container?: TargetsParam;
896
- target?: TargetsParam;
897
- axis?: "x" | "y" | ScrollObserverAxisCallback | ((observer: ScrollObserver) => "x" | "y" | ScrollObserverAxisCallback);
898
- enter?: ScrollThresholdParam | ScrollThresholdValue | ScrollThresholdCallback | ((observer: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback);
899
- leave?: ScrollThresholdParam | ScrollThresholdValue | ScrollThresholdCallback | ((observer: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback);
900
- repeat?: boolean | ((observer: ScrollObserver) => boolean);
901
- debug?: boolean;
902
- onEnter?: Callback<ScrollObserver>;
903
- onLeave?: Callback<ScrollObserver>;
904
- onEnterForward?: Callback<ScrollObserver>;
905
- onLeaveForward?: Callback<ScrollObserver>;
906
- onEnterBackward?: Callback<ScrollObserver>;
907
- onLeaveBackward?: Callback<ScrollObserver>;
908
- onUpdate?: Callback<ScrollObserver>;
909
- onSyncComplete?: Callback<ScrollObserver>;
910
- };
911
981
  declare class ScrollContainer {
912
982
  constructor($el: HTMLElement);
913
983
  element: HTMLElement;
@@ -1021,31 +1091,6 @@ declare namespace waapi {
1021
1091
  export function animate(targets: DOMTargetsParam, params: WAAPIAnimationParams): WAAPIAnimation;
1022
1092
  export { easingToLinear as convertEase };
1023
1093
  }
1024
- type WAAPITweenValue = string | number | Array<string> | Array<number>;
1025
- type WAAPIFunctionvalue = (target: DOMTarget, index: number, length: number) => WAAPITweenValue;
1026
- type WAAPIKeyframeValue = WAAPITweenValue | WAAPIFunctionvalue | Array<string | number | WAAPIFunctionvalue>;
1027
- type WAAPICallback = (animation: WAAPIAnimation) => void;
1028
- type WAAPITweenOptions = {
1029
- to?: WAAPIKeyframeValue;
1030
- from?: WAAPIKeyframeValue;
1031
- duration?: number | WAAPIFunctionvalue;
1032
- delay?: number | WAAPIFunctionvalue;
1033
- ease?: EasingParam;
1034
- composition?: CompositeOperation;
1035
- };
1036
- type WAAPIAnimationOptions = {
1037
- loop?: number | boolean;
1038
- Reversed?: boolean;
1039
- Alternate?: boolean;
1040
- autoplay?: boolean | ScrollObserver;
1041
- playbackRate?: number;
1042
- duration?: number | WAAPIFunctionvalue;
1043
- delay?: number | WAAPIFunctionvalue;
1044
- ease?: EasingParam;
1045
- composition?: CompositeOperation;
1046
- onComplete?: WAAPICallback;
1047
- };
1048
- type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions;
1049
1094
  declare function easingToLinear(fn: EasingFunction, samples?: number): string;
1050
1095
  declare class TextSplitter {
1051
1096
  constructor(target: HTMLElement | NodeList | string | Array<HTMLElement>, parameters?: TextSplitterParams);
@@ -1078,4 +1123,4 @@ declare function split(target: HTMLElement | NodeList | string | Array<HTMLEleme
1078
1123
  declare namespace text {
1079
1124
  export { split };
1080
1125
  }
1081
- export { engine, utils, svg, stagger, eases, DefaultsParams, Renderable, Tickable, CallbackArgument, Revertible, StaggerFunction, StaggerParams, EasingFunction, EaseStringParamNames, EasingParam, DOMTarget, JSTarget, Target, TargetSelector, DOMTargetSelector, DOMTargetsParam, DOMTargetsArray, JSTargetsParam, JSTargetsArray, TargetsParam, TargetsArray, Callback, TickableCallbacks, RenderableCallbacks, TimerOptions, TimerParams, FunctionValue, TweenModifier, ColorArray, Tween, TweenDecomposedValue, TweenPropertySiblings, TweenLookups, TweenReplaceLookups, TweenAdditiveLookups, TweenParamValue, TweenPropValue, TweenComposition, TweenParamsOptions, TweenValues, TweenKeyValue, ArraySyntaxValue, TweenOptions, TweenObjectValue, PercentageKeyframeOptions, PercentageKeyframeParams, PercentageKeyframes, DurationKeyframes, AnimationOptions, AnimationParams, TimelineOptions, TimelineParams, AnimatablePropertySetter, AnimatablePropertyGetter, AnimatableProperty, AnimatableObject, AnimatablePropertyParamsOptions, AnimatableParams, ReactRef, AngularRef, ScopeParams, ScopedCallback, ScopeCleanupCallback, ScopeConstructorCallback, ScopeMethod, DraggableAxisParam, DraggableCursorParams, DraggableParams, splitTemplateParams, SplitValue, SplitFunctionValue, TextSplitterParams, DrawableSVGGeometry, createTimer, Timer, animate, JSAnimation, createTimeline, Timeline, createAnimatable, Animatable, createDraggable, Draggable, createScope, Scope, onScroll, ScrollObserver, scrollContainers, createSpring, Spring, waapi, WAAPIAnimation, text, TextSplitter };
1126
+ export { engine, utils, svg, stagger, eases, DefaultsParams, Renderable, Tickable, CallbackArgument, Revertible, StaggerFunction, StaggerParams, EasingFunction, EaseStringParamNames, EasingParam, DOMTarget, JSTarget, Target, TargetSelector, DOMTargetSelector, DOMTargetsParam, DOMTargetsArray, JSTargetsParam, JSTargetsArray, TargetsParam, TargetsArray, SpringParams, Callback, TickableCallbacks, RenderableCallbacks, TimerOptions, TimerParams, FunctionValue, TweenModifier, ColorArray, Tween, TweenDecomposedValue, TweenPropertySiblings, TweenLookups, TweenReplaceLookups, TweenAdditiveLookups, TweenParamValue, TweenPropValue, TweenComposition, TweenParamsOptions, TweenValues, TweenKeyValue, ArraySyntaxValue, TweenOptions, TweenObjectValue, PercentageKeyframeOptions, PercentageKeyframeParams, PercentageKeyframes, DurationKeyframes, AnimationOptions, AnimationParams, TimelinePosition, TimelineAnimationPosition, TimelineOptions, TimelineParams, WAAPITweenValue, WAAPIFunctionValue, WAAPIKeyframeValue, WAAPICallback, WAAPITweenOptions, WAAPIAnimationOptions, WAAPIAnimationParams, AnimatablePropertySetter, AnimatablePropertyGetter, AnimatableProperty, AnimatableObject, AnimatablePropertyParamsOptions, AnimatableParams, ReactRef, AngularRef, ScopeParams, ScopedCallback, ScopeCleanupCallback, ScopeConstructorCallback, ScopeMethod, ScrollThresholdValue, ScrollThresholdParam, ScrollObserverAxisCallback, ScrollThresholdCallback, ScrollObserverParams, DraggableAxisParam, DraggableCursorParams, DraggableParams, splitTemplateParams, SplitValue, SplitFunctionValue, TextSplitterParams, DrawableSVGGeometry, createTimer, Timer, animate, JSAnimation, createTimeline, Timeline, createAnimatable, Animatable, createDraggable, Draggable, createScope, Scope, onScroll, ScrollObserver, scrollContainers, createSpring, Spring, waapi, WAAPIAnimation, text, TextSplitter };