animejs 4.2.0 → 4.2.2
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/bundles/anime.esm.js +103 -48
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +103 -48
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +2 -2
- package/dist/modules/animatable/animatable.js +2 -2
- package/dist/modules/animatable/index.cjs +1 -1
- package/dist/modules/animatable/index.js +1 -1
- package/dist/modules/animation/additive.cjs +1 -1
- package/dist/modules/animation/additive.js +1 -1
- package/dist/modules/animation/animation.cjs +7 -3
- package/dist/modules/animation/animation.d.ts +8 -3
- package/dist/modules/animation/animation.js +7 -3
- package/dist/modules/animation/composition.cjs +1 -1
- package/dist/modules/animation/composition.js +1 -1
- package/dist/modules/animation/index.cjs +1 -1
- package/dist/modules/animation/index.js +1 -1
- package/dist/modules/core/clock.cjs +1 -1
- package/dist/modules/core/clock.js +1 -1
- package/dist/modules/core/colors.cjs +1 -1
- package/dist/modules/core/colors.js +1 -1
- package/dist/modules/core/consts.cjs +1 -1
- package/dist/modules/core/consts.js +1 -1
- package/dist/modules/core/globals.cjs +2 -2
- package/dist/modules/core/globals.js +2 -2
- package/dist/modules/core/helpers.cjs +1 -1
- package/dist/modules/core/helpers.js +1 -1
- package/dist/modules/core/render.cjs +1 -1
- package/dist/modules/core/render.js +1 -1
- package/dist/modules/core/styles.cjs +1 -1
- package/dist/modules/core/styles.js +1 -1
- package/dist/modules/core/targets.cjs +1 -1
- package/dist/modules/core/targets.js +1 -1
- package/dist/modules/core/transforms.cjs +1 -1
- package/dist/modules/core/transforms.js +1 -1
- package/dist/modules/core/units.cjs +1 -1
- package/dist/modules/core/units.js +1 -1
- package/dist/modules/core/values.cjs +1 -1
- package/dist/modules/core/values.js +1 -1
- package/dist/modules/draggable/draggable.cjs +17 -4
- package/dist/modules/draggable/draggable.d.ts +2 -0
- package/dist/modules/draggable/draggable.js +18 -5
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
- package/dist/modules/easings/cubic-bezier/index.js +1 -1
- package/dist/modules/easings/eases/index.cjs +1 -1
- package/dist/modules/easings/eases/index.js +1 -1
- package/dist/modules/easings/eases/parser.cjs +1 -1
- package/dist/modules/easings/eases/parser.js +1 -1
- package/dist/modules/easings/index.cjs +1 -1
- package/dist/modules/easings/index.js +1 -1
- package/dist/modules/easings/irregular/index.cjs +1 -1
- package/dist/modules/easings/irregular/index.js +1 -1
- package/dist/modules/easings/linear/index.cjs +1 -1
- package/dist/modules/easings/linear/index.js +1 -1
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +1 -1
- package/dist/modules/easings/spring/index.js +1 -1
- package/dist/modules/easings/steps/index.cjs +1 -1
- package/dist/modules/easings/steps/index.js +1 -1
- package/dist/modules/engine/engine.cjs +1 -1
- package/dist/modules/engine/engine.js +1 -1
- package/dist/modules/engine/index.cjs +1 -1
- package/dist/modules/engine/index.js +1 -1
- package/dist/modules/events/index.cjs +1 -1
- package/dist/modules/events/index.js +1 -1
- package/dist/modules/events/scroll.cjs +7 -3
- package/dist/modules/events/scroll.d.ts +2 -0
- package/dist/modules/events/scroll.js +7 -3
- package/dist/modules/index.cjs +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/scope/index.cjs +1 -1
- package/dist/modules/scope/index.js +1 -1
- package/dist/modules/scope/scope.cjs +1 -1
- package/dist/modules/scope/scope.js +1 -1
- package/dist/modules/svg/drawable.cjs +1 -1
- package/dist/modules/svg/drawable.js +1 -1
- package/dist/modules/svg/helpers.cjs +1 -1
- package/dist/modules/svg/helpers.js +1 -1
- package/dist/modules/svg/index.cjs +1 -1
- package/dist/modules/svg/index.js +1 -1
- package/dist/modules/svg/morphto.cjs +12 -2
- package/dist/modules/svg/morphto.js +12 -2
- package/dist/modules/svg/motionpath.cjs +23 -12
- package/dist/modules/svg/motionpath.d.ts +1 -1
- package/dist/modules/svg/motionpath.js +23 -12
- package/dist/modules/text/index.cjs +1 -1
- package/dist/modules/text/index.js +1 -1
- package/dist/modules/text/split.cjs +1 -1
- package/dist/modules/text/split.js +1 -1
- package/dist/modules/timeline/index.cjs +1 -1
- package/dist/modules/timeline/index.js +1 -1
- package/dist/modules/timeline/position.cjs +1 -1
- package/dist/modules/timeline/position.js +1 -1
- package/dist/modules/timeline/timeline.cjs +9 -5
- package/dist/modules/timeline/timeline.d.ts +8 -3
- package/dist/modules/timeline/timeline.js +9 -5
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +17 -14
- package/dist/modules/timer/timer.d.ts +12 -7
- package/dist/modules/timer/timer.js +17 -14
- package/dist/modules/types/index.d.ts +7 -3
- package/dist/modules/utils/chainable.cjs +1 -1
- package/dist/modules/utils/chainable.js +1 -1
- package/dist/modules/utils/index.cjs +1 -1
- package/dist/modules/utils/index.js +1 -1
- package/dist/modules/utils/number.cjs +1 -1
- package/dist/modules/utils/number.js +1 -1
- package/dist/modules/utils/random.cjs +1 -1
- package/dist/modules/utils/random.js +1 -1
- package/dist/modules/utils/stagger.cjs +1 -1
- package/dist/modules/utils/stagger.js +1 -1
- package/dist/modules/utils/target.cjs +1 -1
- package/dist/modules/utils/target.js +1 -1
- package/dist/modules/utils/time.cjs +1 -1
- package/dist/modules/utils/time.js +1 -1
- package/dist/modules/waapi/composition.cjs +1 -1
- package/dist/modules/waapi/composition.js +1 -1
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +8 -5
- package/dist/modules/waapi/waapi.d.ts +8 -5
- package/dist/modules/waapi/waapi.js +8 -5
- package/package.json +3 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - UMD bundle
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.2
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -385,10 +385,6 @@
|
|
|
385
385
|
* @typedef {WAAPITweenValue|WAAPIFunctionValue|Array<String|Number|WAAPIFunctionValue>} WAAPIKeyframeValue
|
|
386
386
|
*/
|
|
387
387
|
|
|
388
|
-
/**
|
|
389
|
-
* @typedef {Callback<WAAPIAnimation>} WAAPICallback
|
|
390
|
-
*/
|
|
391
|
-
|
|
392
388
|
/**
|
|
393
389
|
* @typedef {Object} WAAPITweenOptions
|
|
394
390
|
* @property {WAAPIKeyframeValue} [to]
|
|
@@ -411,11 +407,11 @@
|
|
|
411
407
|
* @property {WAAPIEasingParam} [ease]
|
|
412
408
|
* @property {CompositeOperation} [composition]
|
|
413
409
|
* @property {Boolean} [persist]
|
|
414
|
-
* @property {
|
|
410
|
+
* @property {Callback<WAAPIAnimation>} [onComplete]
|
|
415
411
|
*/
|
|
416
412
|
|
|
417
413
|
/**
|
|
418
|
-
* @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver |
|
|
414
|
+
* @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | Callback<WAAPIAnimation> | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
|
|
419
415
|
*/
|
|
420
416
|
|
|
421
417
|
// Animatable types
|
|
@@ -558,6 +554,12 @@
|
|
|
558
554
|
* @property {String} [onGrab]
|
|
559
555
|
*/
|
|
560
556
|
|
|
557
|
+
/**
|
|
558
|
+
* @typedef {Object} DraggableDragThresholdParams
|
|
559
|
+
* @property {Number} [mouse]
|
|
560
|
+
* @property {Number} [touch]
|
|
561
|
+
*/
|
|
562
|
+
|
|
561
563
|
/**
|
|
562
564
|
* @typedef {Object} DraggableParams
|
|
563
565
|
* @property {DOMTargetSelector} [trigger]
|
|
@@ -570,6 +572,7 @@
|
|
|
570
572
|
* @property {Number|((draggable: Draggable) => Number)} [containerFriction]
|
|
571
573
|
* @property {Number|((draggable: Draggable) => Number)} [releaseContainerFriction]
|
|
572
574
|
* @property {Number|((draggable: Draggable) => Number)} [dragSpeed]
|
|
575
|
+
* @property {Number|DraggableDragThresholdParams|((draggable: Draggable) => Number|DraggableDragThresholdParams)} [dragThreshold]
|
|
573
576
|
* @property {Number|((draggable: Draggable) => Number)} [scrollSpeed]
|
|
574
577
|
* @property {Number|((draggable: Draggable) => Number)} [scrollThreshold]
|
|
575
578
|
* @property {Number|((draggable: Draggable) => Number)} [minVelocity]
|
|
@@ -799,7 +802,7 @@
|
|
|
799
802
|
tickThreshold: 200,
|
|
800
803
|
};
|
|
801
804
|
|
|
802
|
-
const globalVersions = { version: '4.2.
|
|
805
|
+
const globalVersions = { version: '4.2.2', engine: null };
|
|
803
806
|
|
|
804
807
|
if (isBrowser) {
|
|
805
808
|
if (!win.AnimeJS) win.AnimeJS = [];
|
|
@@ -2486,7 +2489,7 @@
|
|
|
2486
2489
|
if (timer._hasChildren) {
|
|
2487
2490
|
forEachChildren(timer, reviveTimer);
|
|
2488
2491
|
} else {
|
|
2489
|
-
forEachChildren(timer, (/** @type {Tween} tween*/tween) => {
|
|
2492
|
+
forEachChildren(timer, (/** @type {Tween} tween */tween) => {
|
|
2490
2493
|
if (tween._composition !== compositionTypes.none) {
|
|
2491
2494
|
composeTween(tween, getTweenSiblings(tween.target, tween.property));
|
|
2492
2495
|
}
|
|
@@ -2543,7 +2546,6 @@
|
|
|
2543
2546
|
/** @type {Number} */(timerLoop) < 0 ? Infinity :
|
|
2544
2547
|
/** @type {Number} */(timerLoop) + 1;
|
|
2545
2548
|
|
|
2546
|
-
|
|
2547
2549
|
let offsetPosition = 0;
|
|
2548
2550
|
|
|
2549
2551
|
if (parent) {
|
|
@@ -2633,7 +2635,7 @@
|
|
|
2633
2635
|
}
|
|
2634
2636
|
|
|
2635
2637
|
set cancelled(cancelled) {
|
|
2636
|
-
cancelled ? this.cancel() : this.reset(
|
|
2638
|
+
cancelled ? this.cancel() : this.reset(true).play();
|
|
2637
2639
|
}
|
|
2638
2640
|
|
|
2639
2641
|
get currentTime() {
|
|
@@ -2698,10 +2700,10 @@
|
|
|
2698
2700
|
}
|
|
2699
2701
|
|
|
2700
2702
|
/**
|
|
2701
|
-
* @param {
|
|
2703
|
+
* @param {Boolean} [softReset]
|
|
2702
2704
|
* @return {this}
|
|
2703
2705
|
*/
|
|
2704
|
-
reset(
|
|
2706
|
+
reset(softReset = false) {
|
|
2705
2707
|
// If cancelled, revive the timer before rendering in order to have propertly composed tweens siblings
|
|
2706
2708
|
reviveTimer(this);
|
|
2707
2709
|
if (this._reversed && !this._reverse) this.reversed = false;
|
|
@@ -2710,7 +2712,7 @@
|
|
|
2710
2712
|
// NOTE: This is only required for Timelines and might be better to move to the Timeline class?
|
|
2711
2713
|
this._iterationTime = this.iterationDuration;
|
|
2712
2714
|
// Set tickMode to tickModes.FORCE to force rendering
|
|
2713
|
-
tick(this, 0, 1,
|
|
2715
|
+
tick(this, 0, 1, ~~softReset, tickModes.FORCE);
|
|
2714
2716
|
// Reset timer properties after revive / render to make sure the props are not updated again
|
|
2715
2717
|
resetTimerProperties(this);
|
|
2716
2718
|
// Also reset children properties
|
|
@@ -2721,16 +2723,16 @@
|
|
|
2721
2723
|
}
|
|
2722
2724
|
|
|
2723
2725
|
/**
|
|
2724
|
-
* @param {
|
|
2726
|
+
* @param {Boolean} internalRender
|
|
2725
2727
|
* @return {this}
|
|
2726
2728
|
*/
|
|
2727
|
-
init(internalRender =
|
|
2729
|
+
init(internalRender = false) {
|
|
2728
2730
|
this.fps = this._fps;
|
|
2729
2731
|
this.speed = this._speed;
|
|
2730
2732
|
// Manually calling .init() on timelines should render all children intial state
|
|
2731
2733
|
// Forces all children to render once then render to 0 when reseted
|
|
2732
2734
|
if (!internalRender && this._hasChildren) {
|
|
2733
|
-
tick(this, this.duration, 1, internalRender, tickModes.FORCE);
|
|
2735
|
+
tick(this, this.duration, 1, ~~internalRender, tickModes.FORCE);
|
|
2734
2736
|
}
|
|
2735
2737
|
this.reset(internalRender);
|
|
2736
2738
|
// Make sure to set autoplay to false to child timers so it doesn't attempt to autoplay / link
|
|
@@ -2784,7 +2786,7 @@
|
|
|
2784
2786
|
|
|
2785
2787
|
/** @return {this} */
|
|
2786
2788
|
restart() {
|
|
2787
|
-
return this.reset(
|
|
2789
|
+
return this.reset().resume();
|
|
2788
2790
|
}
|
|
2789
2791
|
|
|
2790
2792
|
/**
|
|
@@ -2887,8 +2889,12 @@
|
|
|
2887
2889
|
}
|
|
2888
2890
|
|
|
2889
2891
|
/**
|
|
2890
|
-
* @
|
|
2891
|
-
|
|
2892
|
+
* @typedef {this & {then: null}} ResolvedTimer
|
|
2893
|
+
*/
|
|
2894
|
+
|
|
2895
|
+
/**
|
|
2896
|
+
* @param {Callback<ResolvedTimer>} [callback]
|
|
2897
|
+
* @return Promise<this>
|
|
2892
2898
|
*/
|
|
2893
2899
|
then(callback = noop) {
|
|
2894
2900
|
const then = this.then;
|
|
@@ -2896,7 +2902,7 @@
|
|
|
2896
2902
|
// this.then = null prevents infinite recursion if returned by an async function
|
|
2897
2903
|
// https://github.com/juliangarnierorg/anime-beta/issues/26
|
|
2898
2904
|
this.then = null;
|
|
2899
|
-
callback(this);
|
|
2905
|
+
callback(/** @type {ResolvedTimer} */(this));
|
|
2900
2906
|
this.then = then;
|
|
2901
2907
|
this._resolve = noop;
|
|
2902
2908
|
};
|
|
@@ -3845,8 +3851,12 @@
|
|
|
3845
3851
|
}
|
|
3846
3852
|
|
|
3847
3853
|
/**
|
|
3848
|
-
* @
|
|
3849
|
-
|
|
3854
|
+
* @typedef {this & {then: null}} ResolvedJSAnimation
|
|
3855
|
+
*/
|
|
3856
|
+
|
|
3857
|
+
/**
|
|
3858
|
+
* @param {Callback<ResolvedJSAnimation>} [callback]
|
|
3859
|
+
* @return Promise<this>
|
|
3850
3860
|
*/
|
|
3851
3861
|
then(callback) {
|
|
3852
3862
|
return super.then(callback);
|
|
@@ -4117,7 +4127,7 @@
|
|
|
4117
4127
|
const tlChild = targets ?
|
|
4118
4128
|
new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
|
|
4119
4129
|
new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
|
|
4120
|
-
tlChild.init(
|
|
4130
|
+
tlChild.init(true);
|
|
4121
4131
|
// TODO: Might be better to insert at a position relative to startTime?
|
|
4122
4132
|
addChild(tl, tlChild);
|
|
4123
4133
|
forEachChildren(tl, (/** @type {Renderable} */child) => {
|
|
@@ -4221,7 +4231,7 @@
|
|
|
4221
4231
|
parseTimelinePosition(this,a2),
|
|
4222
4232
|
);
|
|
4223
4233
|
}
|
|
4224
|
-
return this.init(
|
|
4234
|
+
return this.init(true);
|
|
4225
4235
|
}
|
|
4226
4236
|
}
|
|
4227
4237
|
|
|
@@ -4330,8 +4340,12 @@
|
|
|
4330
4340
|
}
|
|
4331
4341
|
|
|
4332
4342
|
/**
|
|
4333
|
-
* @
|
|
4334
|
-
|
|
4343
|
+
* @typedef {this & {then: null}} ResolvedTimeline
|
|
4344
|
+
*/
|
|
4345
|
+
|
|
4346
|
+
/**
|
|
4347
|
+
* @param {Callback<ResolvedTimeline>} [callback]
|
|
4348
|
+
* @return Promise<this>
|
|
4335
4349
|
*/
|
|
4336
4350
|
then(callback) {
|
|
4337
4351
|
return super.then(callback);
|
|
@@ -4441,7 +4455,7 @@
|
|
|
4441
4455
|
tween._currentTime = 0;
|
|
4442
4456
|
});
|
|
4443
4457
|
if (!isUnd(duration)) animation.stretch(duration);
|
|
4444
|
-
animation.reset(
|
|
4458
|
+
animation.reset(true).resume();
|
|
4445
4459
|
return this;
|
|
4446
4460
|
}
|
|
4447
4461
|
};
|
|
@@ -4902,7 +4916,7 @@
|
|
|
4902
4916
|
}
|
|
4903
4917
|
|
|
4904
4918
|
/**
|
|
4905
|
-
* @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams} T
|
|
4919
|
+
* @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams|DraggableDragThresholdParams} T
|
|
4906
4920
|
* @param {T | ((draggable: Draggable) => T)} value
|
|
4907
4921
|
* @param {Draggable} draggable
|
|
4908
4922
|
* @return {T}
|
|
@@ -4956,6 +4970,8 @@
|
|
|
4956
4970
|
/** @type {Number} */
|
|
4957
4971
|
this.dragSpeed = 0;
|
|
4958
4972
|
/** @type {Number} */
|
|
4973
|
+
this.dragThreshold = 3;
|
|
4974
|
+
/** @type {Number} */
|
|
4959
4975
|
this.maxVelocity = 0;
|
|
4960
4976
|
/** @type {Number} */
|
|
4961
4977
|
this.minVelocity = 0;
|
|
@@ -5373,6 +5389,16 @@
|
|
|
5373
5389
|
if (onHover) cursorStyles.onHover = onHover;
|
|
5374
5390
|
if (onGrab) cursorStyles.onGrab = onGrab;
|
|
5375
5391
|
}
|
|
5392
|
+
const parsedDragThreshold = parseDraggableFunctionParameter(params.dragThreshold, this);
|
|
5393
|
+
const dragThreshold = { mouse: 3, touch: 7 };
|
|
5394
|
+
if (isNum(parsedDragThreshold)) {
|
|
5395
|
+
dragThreshold.mouse = parsedDragThreshold;
|
|
5396
|
+
dragThreshold.touch = parsedDragThreshold;
|
|
5397
|
+
} else if (parsedDragThreshold) {
|
|
5398
|
+
const { mouse, touch } = parsedDragThreshold;
|
|
5399
|
+
if (!isUnd(mouse)) dragThreshold.mouse = mouse;
|
|
5400
|
+
if (!isUnd(touch)) dragThreshold.touch = touch;
|
|
5401
|
+
}
|
|
5376
5402
|
this.containerArray = isArr(container) ? container : null;
|
|
5377
5403
|
this.$container = /** @type {HTMLElement} */(container && !this.containerArray ? parseTargets(/** @type {DOMTarget} */(container))[0] : doc.body);
|
|
5378
5404
|
this.useWin = this.$container === doc.body;
|
|
@@ -5387,6 +5413,7 @@
|
|
|
5387
5413
|
this.scrollSpeed = setValue(parseDraggableFunctionParameter(params.scrollSpeed, this), 1.5);
|
|
5388
5414
|
this.scrollThreshold = setValue(parseDraggableFunctionParameter(params.scrollThreshold, this), 20);
|
|
5389
5415
|
this.dragSpeed = setValue(parseDraggableFunctionParameter(params.dragSpeed, this), 1);
|
|
5416
|
+
this.dragThreshold = this.isFinePointer ? dragThreshold.mouse : dragThreshold.touch;
|
|
5390
5417
|
this.minVelocity = setValue(parseDraggableFunctionParameter(params.minVelocity, this), 0);
|
|
5391
5418
|
this.maxVelocity = setValue(parseDraggableFunctionParameter(params.maxVelocity, this), 50);
|
|
5392
5419
|
this.velocityMultiplier = setValue(parseDraggableFunctionParameter(params.velocityMultiplier, this), 1);
|
|
@@ -5688,8 +5715,7 @@
|
|
|
5688
5715
|
this.$trigger.addEventListener('touchend', preventDefault);
|
|
5689
5716
|
|
|
5690
5717
|
// Don't check for a miminim distance move if already dragging
|
|
5691
|
-
if (this.dragged || (!this.disabled[0] && abs(movedX) >
|
|
5692
|
-
|
|
5718
|
+
if (this.dragged || (!this.disabled[0] && abs(movedX) > this.dragThreshold) || (!this.disabled[1] && abs(movedY) > this.dragThreshold)) {
|
|
5693
5719
|
this.updateTicker.resume();
|
|
5694
5720
|
this.pointer[2] = this.pointer[0];
|
|
5695
5721
|
this.pointer[3] = this.pointer[1];
|
|
@@ -6278,6 +6304,8 @@
|
|
|
6278
6304
|
/** @type {Number} */
|
|
6279
6305
|
this.top = 0;
|
|
6280
6306
|
/** @type {Number} */
|
|
6307
|
+
this.scale = 1;
|
|
6308
|
+
/** @type {Number} */
|
|
6281
6309
|
this.zIndex = 0;
|
|
6282
6310
|
/** @type {Number} */
|
|
6283
6311
|
this.scrollX = 0;
|
|
@@ -6389,6 +6417,7 @@
|
|
|
6389
6417
|
height = $el.clientHeight;
|
|
6390
6418
|
this.top = elRect.top;
|
|
6391
6419
|
this.left = elRect.left;
|
|
6420
|
+
this.scale = elRect.width ? width / elRect.width : (elRect.height ? height / elRect.height : 1);
|
|
6392
6421
|
}
|
|
6393
6422
|
this.width = width;
|
|
6394
6423
|
this.height = height;
|
|
@@ -6914,8 +6943,9 @@
|
|
|
6914
6943
|
}
|
|
6915
6944
|
}
|
|
6916
6945
|
const rect = $target.getBoundingClientRect();
|
|
6917
|
-
const
|
|
6918
|
-
const
|
|
6946
|
+
const scale = container.scale;
|
|
6947
|
+
const offset = (isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top) * scale;
|
|
6948
|
+
const targetSize = (isHori ? rect.width : rect.height) * scale;
|
|
6919
6949
|
const containerSize = isHori ? container.width : container.height;
|
|
6920
6950
|
const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
|
|
6921
6951
|
const maxScroll = scrollSize - containerSize;
|
|
@@ -7629,36 +7659,46 @@
|
|
|
7629
7659
|
|
|
7630
7660
|
/**
|
|
7631
7661
|
* @param {SVGGeometryElement} $path
|
|
7662
|
+
* @param {Number} totalLength
|
|
7632
7663
|
* @param {Number} progress
|
|
7633
|
-
* @param {Number}lookup
|
|
7664
|
+
* @param {Number} lookup
|
|
7665
|
+
* @param {Boolean} shouldClamp
|
|
7634
7666
|
* @return {DOMPoint}
|
|
7635
7667
|
*/
|
|
7636
|
-
const getPathPoint = ($path, progress, lookup
|
|
7637
|
-
|
|
7668
|
+
const getPathPoint = ($path, totalLength, progress, lookup, shouldClamp) => {
|
|
7669
|
+
const point = progress + lookup;
|
|
7670
|
+
const pointOnPath = shouldClamp
|
|
7671
|
+
? Math.max(0, Math.min(point, totalLength)) // Clamp between 0 and totalLength
|
|
7672
|
+
: (point % totalLength + totalLength) % totalLength; // Wrap around
|
|
7673
|
+
return $path.getPointAtLength(pointOnPath);
|
|
7638
7674
|
};
|
|
7639
7675
|
|
|
7640
7676
|
/**
|
|
7641
7677
|
* @param {SVGGeometryElement} $path
|
|
7642
7678
|
* @param {String} pathProperty
|
|
7679
|
+
* @param {Number} [offset=0]
|
|
7643
7680
|
* @return {FunctionValue}
|
|
7644
7681
|
*/
|
|
7645
|
-
const getPathProgess = ($path, pathProperty) => {
|
|
7682
|
+
const getPathProgess = ($path, pathProperty, offset = 0) => {
|
|
7646
7683
|
return $el => {
|
|
7647
7684
|
const totalLength = +($path.getTotalLength());
|
|
7648
7685
|
const inSvg = $el[isSvgSymbol];
|
|
7649
7686
|
const ctm = $path.getCTM();
|
|
7687
|
+
const shouldClamp = offset === 0;
|
|
7650
7688
|
/** @type {TweenObjectValue} */
|
|
7651
7689
|
return {
|
|
7652
7690
|
from: 0,
|
|
7653
7691
|
to: totalLength,
|
|
7654
7692
|
/** @type {TweenModifier} */
|
|
7655
7693
|
modifier: progress => {
|
|
7694
|
+
const offsetLength = offset * totalLength;
|
|
7695
|
+
const newProgress = progress + offsetLength;
|
|
7656
7696
|
if (pathProperty === 'a') {
|
|
7657
|
-
const p0 = getPathPoint($path,
|
|
7658
|
-
const p1 = getPathPoint($path,
|
|
7697
|
+
const p0 = getPathPoint($path, totalLength, newProgress, -1, shouldClamp);
|
|
7698
|
+
const p1 = getPathPoint($path, totalLength, newProgress, 1, shouldClamp);
|
|
7659
7699
|
return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
|
|
7660
7700
|
} else {
|
|
7661
|
-
const p = getPathPoint($path,
|
|
7701
|
+
const p = getPathPoint($path, totalLength, newProgress, 0, shouldClamp);
|
|
7662
7702
|
return pathProperty === 'x' ?
|
|
7663
7703
|
inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
|
|
7664
7704
|
inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
|
|
@@ -7670,14 +7710,15 @@
|
|
|
7670
7710
|
|
|
7671
7711
|
/**
|
|
7672
7712
|
* @param {TargetsParam} path
|
|
7713
|
+
* @param {Number} [offset=0]
|
|
7673
7714
|
*/
|
|
7674
|
-
const createMotionPath = path => {
|
|
7715
|
+
const createMotionPath = (path, offset = 0) => {
|
|
7675
7716
|
const $path = getPath(path);
|
|
7676
7717
|
if (!$path) return;
|
|
7677
7718
|
return {
|
|
7678
|
-
translateX: getPathProgess($path, 'x'),
|
|
7679
|
-
translateY: getPathProgess($path, 'y'),
|
|
7680
|
-
rotate: getPathProgess($path, 'a'),
|
|
7719
|
+
translateX: getPathProgess($path, 'x', offset),
|
|
7720
|
+
translateY: getPathProgess($path, 'y', offset),
|
|
7721
|
+
rotate: getPathProgess($path, 'a', offset),
|
|
7681
7722
|
}
|
|
7682
7723
|
};
|
|
7683
7724
|
|
|
@@ -7789,8 +7830,18 @@
|
|
|
7789
7830
|
* @return {FunctionValue}
|
|
7790
7831
|
*/
|
|
7791
7832
|
const morphTo = (path2, precision = .33) => ($path1) => {
|
|
7833
|
+
const tagName1 = ($path1.tagName || '').toLowerCase();
|
|
7834
|
+
if (!tagName1.match(/^(path|polygon|polyline)$/)) {
|
|
7835
|
+
throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
|
|
7836
|
+
}
|
|
7792
7837
|
const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
|
|
7793
|
-
if (!$path2)
|
|
7838
|
+
if (!$path2) {
|
|
7839
|
+
throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
|
|
7840
|
+
}
|
|
7841
|
+
const tagName2 = ($path2.tagName || '').toLowerCase();
|
|
7842
|
+
if (!tagName2.match(/^(path|polygon|polyline)$/)) {
|
|
7843
|
+
throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
|
|
7844
|
+
}
|
|
7794
7845
|
const isPath = $path1.tagName === 'path';
|
|
7795
7846
|
const separator = isPath ? ' ' : ',';
|
|
7796
7847
|
const previousPoints = $path1[morphPointsSymbol];
|
|
@@ -8716,14 +8767,18 @@
|
|
|
8716
8767
|
}
|
|
8717
8768
|
|
|
8718
8769
|
/**
|
|
8719
|
-
* @
|
|
8720
|
-
|
|
8770
|
+
* @typedef {this & {then: null}} ResolvedWAAPIAnimation
|
|
8771
|
+
*/
|
|
8772
|
+
|
|
8773
|
+
/**
|
|
8774
|
+
* @param {Callback<ResolvedWAAPIAnimation>} [callback]
|
|
8775
|
+
* @return Promise<this>
|
|
8721
8776
|
*/
|
|
8722
8777
|
then(callback = noop) {
|
|
8723
8778
|
const then = this.then;
|
|
8724
8779
|
const onResolve = () => {
|
|
8725
8780
|
this.then = null;
|
|
8726
|
-
callback(this);
|
|
8781
|
+
callback(/** @type {ResolvedWAAPIAnimation} */(this));
|
|
8727
8782
|
this.then = then;
|
|
8728
8783
|
this._resolve = noop;
|
|
8729
8784
|
};
|