animejs 4.2.0-beta.0 → 4.2.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/README.md +6 -1
- package/dist/bundles/anime.esm.js +543 -304
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +544 -305
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/animatable/animatable.cjs +4 -4
- package/dist/modules/animatable/animatable.js +3 -3
- 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 +28 -17
- package/dist/modules/animation/animation.d.ts +8 -5
- package/dist/modules/animation/animation.js +27 -16
- 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 +7 -2
- package/dist/modules/core/consts.d.ts +2 -0
- package/dist/modules/core/consts.js +6 -3
- package/dist/modules/core/globals.cjs +3 -2
- package/dist/modules/core/globals.js +3 -2
- package/dist/modules/core/helpers.cjs +1 -1
- package/dist/modules/core/helpers.js +1 -1
- package/dist/modules/core/render.cjs +4 -2
- package/dist/modules/core/render.js +4 -2
- package/dist/modules/core/styles.cjs +8 -8
- package/dist/modules/core/styles.js +10 -10
- 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 +17 -6
- package/dist/modules/core/values.js +19 -8
- package/dist/modules/draggable/draggable.cjs +32 -19
- package/dist/modules/draggable/draggable.d.ts +3 -1
- package/dist/modules/draggable/draggable.js +28 -15
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/{cubic-bezier.cjs → cubic-bezier/index.cjs} +4 -4
- package/dist/modules/easings/{cubic-bezier.d.ts → cubic-bezier/index.d.ts} +1 -1
- package/dist/modules/easings/{cubic-bezier.js → cubic-bezier/index.js} +4 -4
- package/dist/modules/easings/eases/index.cjs +14 -0
- package/dist/modules/easings/eases/index.d.ts +1 -0
- package/dist/modules/easings/eases/index.js +8 -0
- package/dist/modules/easings/{eases.cjs → eases/parser.cjs} +69 -27
- package/dist/modules/easings/{eases.d.ts → eases/parser.d.ts} +31 -17
- package/dist/modules/easings/{eases.js → eases/parser.js} +60 -21
- package/dist/modules/easings/index.cjs +15 -13
- package/dist/modules/easings/index.d.ts +6 -6
- package/dist/modules/easings/index.js +7 -7
- package/dist/modules/easings/{irregular.cjs → irregular/index.cjs} +5 -5
- package/dist/modules/easings/{irregular.d.ts → irregular/index.d.ts} +1 -1
- package/dist/modules/easings/{irregular.js → irregular/index.js} +4 -4
- package/dist/modules/easings/{linear.cjs → linear/index.cjs} +4 -4
- package/dist/modules/easings/{linear.d.ts → linear/index.d.ts} +1 -1
- package/dist/modules/easings/{linear.js → linear/index.js} +4 -4
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +255 -0
- package/dist/modules/{spring/spring.d.ts → easings/spring/index.d.ts} +21 -5
- package/dist/modules/easings/spring/index.js +251 -0
- package/dist/modules/easings/{steps.cjs → steps/index.cjs} +3 -3
- package/dist/modules/easings/{steps.d.ts → steps/index.d.ts} +1 -1
- package/dist/modules/easings/{steps.js → steps/index.js} +3 -3
- 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 +17 -9
- package/dist/modules/events/scroll.d.ts +4 -0
- package/dist/modules/events/scroll.js +16 -8
- package/dist/modules/index.cjs +15 -16
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +7 -8
- 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 +18 -11
- package/dist/modules/svg/motionpath.d.ts +1 -1
- package/dist/modules/svg/motionpath.js +18 -11
- 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 +11 -7
- package/dist/modules/timeline/timeline.d.ts +8 -3
- package/dist/modules/timeline/timeline.js +10 -6
- 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 +35 -14
- 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 +4 -4
- package/dist/modules/utils/stagger.js +3 -3
- 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 +11 -5
- package/dist/modules/waapi/composition.d.ts +1 -1
- package/dist/modules/waapi/composition.js +11 -5
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +58 -36
- package/dist/modules/waapi/waapi.d.ts +12 -7
- package/dist/modules/waapi/waapi.js +59 -37
- package/package.json +48 -13
- package/dist/modules/easings/parser.cjs +0 -59
- package/dist/modules/easings/parser.d.ts +0 -21
- package/dist/modules/easings/parser.js +0 -55
- package/dist/modules/spring/index.cjs +0 -15
- package/dist/modules/spring/index.d.ts +0 -1
- package/dist/modules/spring/index.js +0 -8
- package/dist/modules/spring/spring.cjs +0 -133
- package/dist/modules/spring/spring.js +0 -130
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -10,9 +10,6 @@
|
|
|
10
10
|
var consts = require('./consts.cjs');
|
|
11
11
|
var helpers = require('./helpers.cjs');
|
|
12
12
|
|
|
13
|
-
const propertyNamesCache = {};
|
|
14
|
-
|
|
15
|
-
|
|
16
13
|
/**
|
|
17
14
|
* @import {
|
|
18
15
|
* JSAnimation,
|
|
@@ -28,6 +25,8 @@ const propertyNamesCache = {};
|
|
|
28
25
|
* } from '../types/index.js'
|
|
29
26
|
*/
|
|
30
27
|
|
|
28
|
+
const propertyNamesCache = {};
|
|
29
|
+
|
|
31
30
|
/**
|
|
32
31
|
* @param {String} propertyName
|
|
33
32
|
* @param {Target} target
|
|
@@ -74,10 +73,11 @@ const cleanInlineStyles = renderable => {
|
|
|
74
73
|
const tweenTarget = tween.target;
|
|
75
74
|
if (tweenTarget[consts.isDomSymbol]) {
|
|
76
75
|
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
|
|
77
|
-
const originalInlinedValue =
|
|
76
|
+
const originalInlinedValue = tween._inlineValue;
|
|
77
|
+
const tweenHadNoInlineValue = helpers.isNil(originalInlinedValue) || originalInlinedValue === consts.emptyString;
|
|
78
78
|
if (tween._tweenType === consts.tweenTypes.TRANSFORM) {
|
|
79
79
|
const cachedTransforms = tweenTarget[consts.transformsSymbol];
|
|
80
|
-
if (
|
|
80
|
+
if (tweenHadNoInlineValue) {
|
|
81
81
|
delete cachedTransforms[tweenProperty];
|
|
82
82
|
} else {
|
|
83
83
|
cachedTransforms[tweenProperty] = originalInlinedValue;
|
|
@@ -94,8 +94,8 @@ const cleanInlineStyles = renderable => {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
} else {
|
|
97
|
-
if (
|
|
98
|
-
targetStyle.removeProperty(tweenProperty);
|
|
97
|
+
if (tweenHadNoInlineValue) {
|
|
98
|
+
targetStyle.removeProperty(helpers.toLowerCase(tweenProperty));
|
|
99
99
|
} else {
|
|
100
100
|
targetStyle[tweenProperty] = originalInlinedValue;
|
|
101
101
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { tweenTypes, shortTransforms, isDomSymbol, transformsSymbol,
|
|
9
|
-
import { forEachChildren, isSvg, toLowerCase,
|
|
10
|
-
|
|
11
|
-
const propertyNamesCache = {};
|
|
12
|
-
|
|
8
|
+
import { tweenTypes, shortTransforms, isDomSymbol, transformsSymbol, transformsFragmentStrings, emptyString } from './consts.js';
|
|
9
|
+
import { forEachChildren, isSvg, toLowerCase, isNil } from './helpers.js';
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
* @import {
|
|
@@ -26,6 +23,8 @@ const propertyNamesCache = {};
|
|
|
26
23
|
* } from '../types/index.js'
|
|
27
24
|
*/
|
|
28
25
|
|
|
26
|
+
const propertyNamesCache = {};
|
|
27
|
+
|
|
29
28
|
/**
|
|
30
29
|
* @param {String} propertyName
|
|
31
30
|
* @param {Target} target
|
|
@@ -72,10 +71,11 @@ const cleanInlineStyles = renderable => {
|
|
|
72
71
|
const tweenTarget = tween.target;
|
|
73
72
|
if (tweenTarget[isDomSymbol]) {
|
|
74
73
|
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
|
|
75
|
-
const originalInlinedValue =
|
|
74
|
+
const originalInlinedValue = tween._inlineValue;
|
|
75
|
+
const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
|
|
76
76
|
if (tween._tweenType === tweenTypes.TRANSFORM) {
|
|
77
77
|
const cachedTransforms = tweenTarget[transformsSymbol];
|
|
78
|
-
if (
|
|
78
|
+
if (tweenHadNoInlineValue) {
|
|
79
79
|
delete cachedTransforms[tweenProperty];
|
|
80
80
|
} else {
|
|
81
81
|
cachedTransforms[tweenProperty] = originalInlinedValue;
|
|
@@ -92,8 +92,8 @@ const cleanInlineStyles = renderable => {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
|
-
if (
|
|
96
|
-
targetStyle.removeProperty(tweenProperty);
|
|
95
|
+
if (tweenHadNoInlineValue) {
|
|
96
|
+
targetStyle.removeProperty(toLowerCase(tweenProperty));
|
|
97
97
|
} else {
|
|
98
98
|
targetStyle[tweenProperty] = originalInlinedValue;
|
|
99
99
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -41,19 +41,30 @@ const setValue = (targetValue, defaultValue) => {
|
|
|
41
41
|
* @return {any}
|
|
42
42
|
*/
|
|
43
43
|
const getFunctionValue = (value, target, index, total, store) => {
|
|
44
|
+
let func;
|
|
44
45
|
if (helpers.isFnc(value)) {
|
|
45
|
-
|
|
46
|
+
func = () => {
|
|
46
47
|
const computed = /** @type {Function} */(value)(target, index, total);
|
|
47
48
|
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
|
|
48
49
|
return !isNaN(+computed) ? +computed : computed || 0;
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
} else if (helpers.isStr(value) && helpers.stringStartsWith(value, consts.cssVarPrefix)) {
|
|
52
|
+
func = () => {
|
|
53
|
+
const match = value.match(consts.cssVariableMatchRgx);
|
|
54
|
+
const cssVarName = match[1];
|
|
55
|
+
const fallbackValue = match[2];
|
|
56
|
+
let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
|
|
57
|
+
// Use fallback if CSS variable is not set or empty
|
|
58
|
+
if ((!computed || computed.trim() === consts.emptyString) && fallbackValue) {
|
|
59
|
+
computed = fallbackValue.trim();
|
|
60
|
+
}
|
|
61
|
+
return computed || 0;
|
|
62
|
+
};
|
|
54
63
|
} else {
|
|
55
64
|
return value;
|
|
56
65
|
}
|
|
66
|
+
if (store) store.func = func;
|
|
67
|
+
return func();
|
|
57
68
|
};
|
|
58
69
|
|
|
59
70
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - core - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, proxyTargetSymbol } from './consts.js';
|
|
9
|
-
import { isValidSVGAttribute, stringStartsWith,
|
|
8
|
+
import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, proxyTargetSymbol, cssVarPrefix, cssVariableMatchRgx, emptyString } from './consts.js';
|
|
9
|
+
import { isUnd, isValidSVGAttribute, stringStartsWith, isCol, isFnc, isStr, cloneArray } from './helpers.js';
|
|
10
10
|
import { parseInlineTransforms } from './transforms.js';
|
|
11
11
|
import { convertColorStringValuesToRgbaArray } from './colors.js';
|
|
12
12
|
|
|
@@ -39,19 +39,30 @@ const setValue = (targetValue, defaultValue) => {
|
|
|
39
39
|
* @return {any}
|
|
40
40
|
*/
|
|
41
41
|
const getFunctionValue = (value, target, index, total, store) => {
|
|
42
|
+
let func;
|
|
42
43
|
if (isFnc(value)) {
|
|
43
|
-
|
|
44
|
+
func = () => {
|
|
44
45
|
const computed = /** @type {Function} */(value)(target, index, total);
|
|
45
46
|
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
|
|
46
47
|
return !isNaN(+computed) ? +computed : computed || 0;
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
} else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
|
|
50
|
+
func = () => {
|
|
51
|
+
const match = value.match(cssVariableMatchRgx);
|
|
52
|
+
const cssVarName = match[1];
|
|
53
|
+
const fallbackValue = match[2];
|
|
54
|
+
let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
|
|
55
|
+
// Use fallback if CSS variable is not set or empty
|
|
56
|
+
if ((!computed || computed.trim() === emptyString) && fallbackValue) {
|
|
57
|
+
computed = fallbackValue.trim();
|
|
58
|
+
}
|
|
59
|
+
return computed || 0;
|
|
60
|
+
};
|
|
52
61
|
} else {
|
|
53
62
|
return value;
|
|
54
63
|
}
|
|
64
|
+
if (store) store.func = func;
|
|
65
|
+
return func();
|
|
55
66
|
};
|
|
56
67
|
|
|
57
68
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - draggable - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -17,8 +17,8 @@ var timer = require('../timer/timer.cjs');
|
|
|
17
17
|
var animation = require('../animation/animation.cjs');
|
|
18
18
|
var composition = require('../animation/composition.cjs');
|
|
19
19
|
var animatable = require('../animatable/animatable.cjs');
|
|
20
|
-
var
|
|
21
|
-
var
|
|
20
|
+
var parser = require('../easings/eases/parser.cjs');
|
|
21
|
+
var index = require('../easings/spring/index.cjs');
|
|
22
22
|
var target = require('../utils/target.cjs');
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -26,6 +26,7 @@ var target = require('../utils/target.cjs');
|
|
|
26
26
|
* DOMTarget,
|
|
27
27
|
* DOMTargetSelector,
|
|
28
28
|
* DraggableCursorParams,
|
|
29
|
+
* DraggableDragThresholdParams,
|
|
29
30
|
* TargetsParam,
|
|
30
31
|
* DraggableParams,
|
|
31
32
|
* EasingFunction,
|
|
@@ -40,7 +41,7 @@ var target = require('../utils/target.cjs');
|
|
|
40
41
|
/**
|
|
41
42
|
* @import {
|
|
42
43
|
* Spring,
|
|
43
|
-
* } from '../spring/
|
|
44
|
+
* } from '../easings/spring/index.js'
|
|
44
45
|
*/
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -156,7 +157,7 @@ class Transforms {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
/**
|
|
159
|
-
* @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams} T
|
|
160
|
+
* @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams|DraggableDragThresholdParams} T
|
|
160
161
|
* @param {T | ((draggable: Draggable) => T)} value
|
|
161
162
|
* @param {Draggable} draggable
|
|
162
163
|
* @return {T}
|
|
@@ -178,7 +179,7 @@ class Draggable {
|
|
|
178
179
|
const trigger = parameters.trigger;
|
|
179
180
|
const modifier = parameters.modifier;
|
|
180
181
|
const ease = parameters.releaseEase;
|
|
181
|
-
const customEase = ease &&
|
|
182
|
+
const customEase = ease && parser.parseEase(ease);
|
|
182
183
|
const hasSpring = !helpers.isUnd(ease) && !helpers.isUnd(/** @type {Spring} */(ease).ease);
|
|
183
184
|
const xProp = /** @type {String} */(helpers.isObj(paramX) && !helpers.isUnd(/** @type {Object} */(paramX).mapTo) ? /** @type {Object} */(paramX).mapTo : 'translateX');
|
|
184
185
|
const yProp = /** @type {String} */(helpers.isObj(paramY) && !helpers.isUnd(/** @type {Object} */(paramY).mapTo) ? /** @type {Object} */(paramY).mapTo : 'translateY');
|
|
@@ -210,6 +211,8 @@ class Draggable {
|
|
|
210
211
|
/** @type {Number} */
|
|
211
212
|
this.dragSpeed = 0;
|
|
212
213
|
/** @type {Number} */
|
|
214
|
+
this.dragThreshold = 3;
|
|
215
|
+
/** @type {Number} */
|
|
213
216
|
this.maxVelocity = 0;
|
|
214
217
|
/** @type {Number} */
|
|
215
218
|
this.minVelocity = 0;
|
|
@@ -218,19 +221,19 @@ class Draggable {
|
|
|
218
221
|
/** @type {Boolean|DraggableCursorParams} */
|
|
219
222
|
this.cursor = false;
|
|
220
223
|
/** @type {Spring} */
|
|
221
|
-
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring
|
|
224
|
+
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : index.spring({
|
|
222
225
|
mass: values.setValue(parameters.releaseMass, 1),
|
|
223
226
|
stiffness: values.setValue(parameters.releaseStiffness, 80),
|
|
224
227
|
damping: values.setValue(parameters.releaseDamping, 20),
|
|
225
228
|
});
|
|
226
229
|
/** @type {Spring} */
|
|
227
|
-
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring
|
|
230
|
+
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : index.spring({
|
|
228
231
|
mass: values.setValue(parameters.releaseMass, 1),
|
|
229
232
|
stiffness: values.setValue(parameters.releaseStiffness, 80),
|
|
230
233
|
damping: values.setValue(parameters.releaseDamping, 20),
|
|
231
234
|
});
|
|
232
235
|
/** @type {EasingFunction} */
|
|
233
|
-
this.releaseEase = customEase ||
|
|
236
|
+
this.releaseEase = customEase || parser.eases.outQuint;
|
|
234
237
|
/** @type {Boolean} */
|
|
235
238
|
this.hasReleaseSpring = hasSpring;
|
|
236
239
|
/** @type {Callback<this>} */
|
|
@@ -627,6 +630,16 @@ class Draggable {
|
|
|
627
630
|
if (onHover) cursorStyles.onHover = onHover;
|
|
628
631
|
if (onGrab) cursorStyles.onGrab = onGrab;
|
|
629
632
|
}
|
|
633
|
+
const parsedDragThreshold = parseDraggableFunctionParameter(params.dragThreshold, this);
|
|
634
|
+
const dragThreshold = { mouse: 3, touch: 7 };
|
|
635
|
+
if (helpers.isNum(parsedDragThreshold)) {
|
|
636
|
+
dragThreshold.mouse = parsedDragThreshold;
|
|
637
|
+
dragThreshold.touch = parsedDragThreshold;
|
|
638
|
+
} else if (parsedDragThreshold) {
|
|
639
|
+
const { mouse, touch } = parsedDragThreshold;
|
|
640
|
+
if (!helpers.isUnd(mouse)) dragThreshold.mouse = mouse;
|
|
641
|
+
if (!helpers.isUnd(touch)) dragThreshold.touch = touch;
|
|
642
|
+
}
|
|
630
643
|
this.containerArray = helpers.isArr(container) ? container : null;
|
|
631
644
|
this.$container = /** @type {HTMLElement} */(container && !this.containerArray ? targets.parseTargets(/** @type {DOMTarget} */(container))[0] : consts.doc.body);
|
|
632
645
|
this.useWin = this.$container === consts.doc.body;
|
|
@@ -641,6 +654,7 @@ class Draggable {
|
|
|
641
654
|
this.scrollSpeed = values.setValue(parseDraggableFunctionParameter(params.scrollSpeed, this), 1.5);
|
|
642
655
|
this.scrollThreshold = values.setValue(parseDraggableFunctionParameter(params.scrollThreshold, this), 20);
|
|
643
656
|
this.dragSpeed = values.setValue(parseDraggableFunctionParameter(params.dragSpeed, this), 1);
|
|
657
|
+
this.dragThreshold = this.isFinePointer ? dragThreshold.mouse : dragThreshold.touch;
|
|
644
658
|
this.minVelocity = values.setValue(parseDraggableFunctionParameter(params.minVelocity, this), 0);
|
|
645
659
|
this.maxVelocity = values.setValue(parseDraggableFunctionParameter(params.maxVelocity, this), 50);
|
|
646
660
|
this.velocityMultiplier = values.setValue(parseDraggableFunctionParameter(params.velocityMultiplier, this), 1);
|
|
@@ -753,7 +767,7 @@ class Draggable {
|
|
|
753
767
|
* @param {EasingParam} [ease]
|
|
754
768
|
* @return {this}
|
|
755
769
|
*/
|
|
756
|
-
scrollInView(duration, gap = 0, ease =
|
|
770
|
+
scrollInView(duration, gap = 0, ease = parser.eases.inOutQuad) {
|
|
757
771
|
this.updateScrollCoords();
|
|
758
772
|
const x = this.destX;
|
|
759
773
|
const y = this.destY;
|
|
@@ -796,7 +810,7 @@ class Draggable {
|
|
|
796
810
|
* @param {EasingParam} [ease]
|
|
797
811
|
* @return {this}
|
|
798
812
|
*/
|
|
799
|
-
animateInView(duration, gap = 0, ease =
|
|
813
|
+
animateInView(duration, gap = 0, ease = parser.eases.inOutQuad) {
|
|
800
814
|
this.stop();
|
|
801
815
|
this.updateBoundingValues();
|
|
802
816
|
const x = this.x;
|
|
@@ -877,7 +891,7 @@ class Draggable {
|
|
|
877
891
|
cursor: /** @type {DraggableCursorParams} */(this.cursor).onGrab
|
|
878
892
|
});
|
|
879
893
|
}
|
|
880
|
-
this.scrollInView(100, 0,
|
|
894
|
+
this.scrollInView(100, 0, parser.eases.out(3));
|
|
881
895
|
this.onGrab(this);
|
|
882
896
|
|
|
883
897
|
consts.doc.addEventListener('touchmove', this);
|
|
@@ -941,9 +955,8 @@ class Draggable {
|
|
|
941
955
|
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
|
|
942
956
|
this.$trigger.addEventListener('touchend', preventDefault);
|
|
943
957
|
|
|
944
|
-
|
|
945
|
-
if ((!this.disabled[0] && helpers.abs(movedX) >
|
|
946
|
-
|
|
958
|
+
// Don't check for a miminim distance move if already dragging
|
|
959
|
+
if (this.dragged || (!this.disabled[0] && helpers.abs(movedX) > this.dragThreshold) || (!this.disabled[1] && helpers.abs(movedY) > this.dragThreshold)) {
|
|
947
960
|
this.updateTicker.resume();
|
|
948
961
|
this.pointer[2] = this.pointer[0];
|
|
949
962
|
this.pointer[3] = this.pointer[1];
|
|
@@ -1008,8 +1021,8 @@ class Draggable {
|
|
|
1008
1021
|
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
|
|
1009
1022
|
const distanceX = helpers.round(cx - dx, 0);
|
|
1010
1023
|
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / helpers.abs(distanceX) : 0 : pv;
|
|
1011
|
-
const { ease,
|
|
1012
|
-
durationX = cx === dx ? 0 : hasReleaseSpring ?
|
|
1024
|
+
const { ease, settlingDuration, restDuration } = springX;
|
|
1025
|
+
durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.globals.timeScale);
|
|
1013
1026
|
if (hasReleaseSpring) easeX = ease;
|
|
1014
1027
|
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
|
|
1015
1028
|
}
|
|
@@ -1018,8 +1031,8 @@ class Draggable {
|
|
|
1018
1031
|
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
|
|
1019
1032
|
const distanceY = helpers.round(cy - dy, 0);
|
|
1020
1033
|
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / helpers.abs(distanceY) : 0 : pv;
|
|
1021
|
-
const { ease,
|
|
1022
|
-
durationY = cy === dy ? 0 : hasReleaseSpring ?
|
|
1034
|
+
const { ease, settlingDuration, restDuration } = springY;
|
|
1035
|
+
durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.globals.timeScale);
|
|
1023
1036
|
if (hasReleaseSpring) easeY = ease;
|
|
1024
1037
|
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
|
|
1025
1038
|
}
|
|
@@ -30,6 +30,8 @@ export class Draggable {
|
|
|
30
30
|
/** @type {Number} */
|
|
31
31
|
dragSpeed: number;
|
|
32
32
|
/** @type {Number} */
|
|
33
|
+
dragThreshold: number;
|
|
34
|
+
/** @type {Number} */
|
|
33
35
|
maxVelocity: number;
|
|
34
36
|
/** @type {Number} */
|
|
35
37
|
minVelocity: number;
|
|
@@ -206,7 +208,7 @@ export class Draggable {
|
|
|
206
208
|
}
|
|
207
209
|
export function createDraggable(target: TargetsParam, parameters?: DraggableParams): Draggable;
|
|
208
210
|
import type { DraggableCursorParams } from '../types/index.js';
|
|
209
|
-
import type { Spring } from '../spring/
|
|
211
|
+
import type { Spring } from '../easings/spring/index.js';
|
|
210
212
|
import type { EasingFunction } from '../types/index.js';
|
|
211
213
|
import type { Callback } from '../types/index.js';
|
|
212
214
|
import type { AnimatableObject } from '../types/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - draggable - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
import { globals, scope } from '../core/globals.js';
|
|
9
9
|
import { doc, win, noop, maxValue, compositionTypes } from '../core/consts.js';
|
|
10
10
|
import { parseTargets } from '../core/targets.js';
|
|
11
|
-
import { isUnd, isObj, isArr, now, atan2, round, max, snap, clamp, abs, sqrt, cos, sin, isFnc } from '../core/helpers.js';
|
|
11
|
+
import { isUnd, isObj, isArr, now, atan2, round, max, snap, clamp, isNum, abs, sqrt, cos, sin, isFnc } from '../core/helpers.js';
|
|
12
12
|
import { setValue } from '../core/values.js';
|
|
13
13
|
import { mapRange } from '../utils/number.js';
|
|
14
14
|
import { Timer } from '../timer/timer.js';
|
|
15
15
|
import { JSAnimation } from '../animation/animation.js';
|
|
16
16
|
import { removeTargetsFromRenderable } from '../animation/composition.js';
|
|
17
17
|
import { Animatable } from '../animatable/animatable.js';
|
|
18
|
-
import { parseEase, eases } from '../easings/eases.js';
|
|
19
|
-
import {
|
|
18
|
+
import { parseEase, eases } from '../easings/eases/parser.js';
|
|
19
|
+
import { spring } from '../easings/spring/index.js';
|
|
20
20
|
import { get, set } from '../utils/target.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -24,6 +24,7 @@ import { get, set } from '../utils/target.js';
|
|
|
24
24
|
* DOMTarget,
|
|
25
25
|
* DOMTargetSelector,
|
|
26
26
|
* DraggableCursorParams,
|
|
27
|
+
* DraggableDragThresholdParams,
|
|
27
28
|
* TargetsParam,
|
|
28
29
|
* DraggableParams,
|
|
29
30
|
* EasingFunction,
|
|
@@ -38,7 +39,7 @@ import { get, set } from '../utils/target.js';
|
|
|
38
39
|
/**
|
|
39
40
|
* @import {
|
|
40
41
|
* Spring,
|
|
41
|
-
* } from '../spring/
|
|
42
|
+
* } from '../easings/spring/index.js'
|
|
42
43
|
*/
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -154,7 +155,7 @@ class Transforms {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/**
|
|
157
|
-
* @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams} T
|
|
158
|
+
* @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams|DraggableDragThresholdParams} T
|
|
158
159
|
* @param {T | ((draggable: Draggable) => T)} value
|
|
159
160
|
* @param {Draggable} draggable
|
|
160
161
|
* @return {T}
|
|
@@ -208,6 +209,8 @@ class Draggable {
|
|
|
208
209
|
/** @type {Number} */
|
|
209
210
|
this.dragSpeed = 0;
|
|
210
211
|
/** @type {Number} */
|
|
212
|
+
this.dragThreshold = 3;
|
|
213
|
+
/** @type {Number} */
|
|
211
214
|
this.maxVelocity = 0;
|
|
212
215
|
/** @type {Number} */
|
|
213
216
|
this.minVelocity = 0;
|
|
@@ -216,13 +219,13 @@ class Draggable {
|
|
|
216
219
|
/** @type {Boolean|DraggableCursorParams} */
|
|
217
220
|
this.cursor = false;
|
|
218
221
|
/** @type {Spring} */
|
|
219
|
-
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) :
|
|
222
|
+
this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
|
|
220
223
|
mass: setValue(parameters.releaseMass, 1),
|
|
221
224
|
stiffness: setValue(parameters.releaseStiffness, 80),
|
|
222
225
|
damping: setValue(parameters.releaseDamping, 20),
|
|
223
226
|
});
|
|
224
227
|
/** @type {Spring} */
|
|
225
|
-
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) :
|
|
228
|
+
this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
|
|
226
229
|
mass: setValue(parameters.releaseMass, 1),
|
|
227
230
|
stiffness: setValue(parameters.releaseStiffness, 80),
|
|
228
231
|
damping: setValue(parameters.releaseDamping, 20),
|
|
@@ -625,6 +628,16 @@ class Draggable {
|
|
|
625
628
|
if (onHover) cursorStyles.onHover = onHover;
|
|
626
629
|
if (onGrab) cursorStyles.onGrab = onGrab;
|
|
627
630
|
}
|
|
631
|
+
const parsedDragThreshold = parseDraggableFunctionParameter(params.dragThreshold, this);
|
|
632
|
+
const dragThreshold = { mouse: 3, touch: 7 };
|
|
633
|
+
if (isNum(parsedDragThreshold)) {
|
|
634
|
+
dragThreshold.mouse = parsedDragThreshold;
|
|
635
|
+
dragThreshold.touch = parsedDragThreshold;
|
|
636
|
+
} else if (parsedDragThreshold) {
|
|
637
|
+
const { mouse, touch } = parsedDragThreshold;
|
|
638
|
+
if (!isUnd(mouse)) dragThreshold.mouse = mouse;
|
|
639
|
+
if (!isUnd(touch)) dragThreshold.touch = touch;
|
|
640
|
+
}
|
|
628
641
|
this.containerArray = isArr(container) ? container : null;
|
|
629
642
|
this.$container = /** @type {HTMLElement} */(container && !this.containerArray ? parseTargets(/** @type {DOMTarget} */(container))[0] : doc.body);
|
|
630
643
|
this.useWin = this.$container === doc.body;
|
|
@@ -639,6 +652,7 @@ class Draggable {
|
|
|
639
652
|
this.scrollSpeed = setValue(parseDraggableFunctionParameter(params.scrollSpeed, this), 1.5);
|
|
640
653
|
this.scrollThreshold = setValue(parseDraggableFunctionParameter(params.scrollThreshold, this), 20);
|
|
641
654
|
this.dragSpeed = setValue(parseDraggableFunctionParameter(params.dragSpeed, this), 1);
|
|
655
|
+
this.dragThreshold = this.isFinePointer ? dragThreshold.mouse : dragThreshold.touch;
|
|
642
656
|
this.minVelocity = setValue(parseDraggableFunctionParameter(params.minVelocity, this), 0);
|
|
643
657
|
this.maxVelocity = setValue(parseDraggableFunctionParameter(params.maxVelocity, this), 50);
|
|
644
658
|
this.velocityMultiplier = setValue(parseDraggableFunctionParameter(params.velocityMultiplier, this), 1);
|
|
@@ -939,9 +953,8 @@ class Draggable {
|
|
|
939
953
|
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
|
|
940
954
|
this.$trigger.addEventListener('touchend', preventDefault);
|
|
941
955
|
|
|
942
|
-
|
|
943
|
-
if ((!this.disabled[0] && abs(movedX) >
|
|
944
|
-
|
|
956
|
+
// Don't check for a miminim distance move if already dragging
|
|
957
|
+
if (this.dragged || (!this.disabled[0] && abs(movedX) > this.dragThreshold) || (!this.disabled[1] && abs(movedY) > this.dragThreshold)) {
|
|
945
958
|
this.updateTicker.resume();
|
|
946
959
|
this.pointer[2] = this.pointer[0];
|
|
947
960
|
this.pointer[3] = this.pointer[1];
|
|
@@ -1006,8 +1019,8 @@ class Draggable {
|
|
|
1006
1019
|
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
|
|
1007
1020
|
const distanceX = round(cx - dx, 0);
|
|
1008
1021
|
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
|
|
1009
|
-
const { ease,
|
|
1010
|
-
durationX = cx === dx ? 0 : hasReleaseSpring ?
|
|
1022
|
+
const { ease, settlingDuration, restDuration } = springX;
|
|
1023
|
+
durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
|
|
1011
1024
|
if (hasReleaseSpring) easeX = ease;
|
|
1012
1025
|
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
|
|
1013
1026
|
}
|
|
@@ -1016,8 +1029,8 @@ class Draggable {
|
|
|
1016
1029
|
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
|
|
1017
1030
|
const distanceY = round(cy - dy, 0);
|
|
1018
1031
|
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
|
|
1019
|
-
const { ease,
|
|
1020
|
-
durationY = cy === dy ? 0 : hasReleaseSpring ?
|
|
1032
|
+
const { ease, settlingDuration, restDuration } = springY;
|
|
1033
|
+
durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
|
|
1021
1034
|
if (hasReleaseSpring) easeY = ease;
|
|
1022
1035
|
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
|
|
1023
1036
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - CJS
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
var helpers = require('
|
|
11
|
-
var none = require('
|
|
10
|
+
var helpers = require('../../core/helpers.cjs');
|
|
11
|
+
var none = require('../none.cjs');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @import {
|
|
15
15
|
* EasingFunction,
|
|
16
|
-
* } from '
|
|
16
|
+
* } from '../../types/index.js'
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function cubicBezier(mX1?: number, mY1?: number, mX2?: number, mY2?: number): EasingFunction;
|
|
2
|
-
import type { EasingFunction } from '
|
|
2
|
+
import type { EasingFunction } from '../../types/index.js';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - easings - ESM
|
|
3
|
-
* @version v4.2.
|
|
3
|
+
* @version v4.2.1
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2025 - Julian Garnier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { abs } from '
|
|
9
|
-
import { none } from '
|
|
8
|
+
import { abs } from '../../core/helpers.js';
|
|
9
|
+
import { none } from '../none.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @import {
|
|
13
13
|
* EasingFunction,
|
|
14
|
-
* } from '
|
|
14
|
+
* } from '../../types/index.js'
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { eases } from "./parser.js";
|