vevet 3.0.0-beta.2 → 3.0.0-beta.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/lib/cjs/version.js +1 -1
- package/lib/esm/Application/events/PageLoad/index.js +28 -54
- package/lib/esm/Application/events/PageLoad/index.js.map +1 -1
- package/lib/esm/Application/events/Viewport/index.js +107 -180
- package/lib/esm/Application/events/Viewport/index.js.map +1 -1
- package/lib/esm/Application/index.js +96 -178
- package/lib/esm/Application/index.js.map +1 -1
- package/lib/esm/base/Callbacks/index.js +45 -78
- package/lib/esm/base/Callbacks/index.js.map +1 -1
- package/lib/esm/base/Component/index.js +10 -31
- package/lib/esm/base/Component/index.js.map +1 -1
- package/lib/esm/base/Module/index.js +77 -132
- package/lib/esm/base/Module/index.js.map +1 -1
- package/lib/esm/base/MutableProps/index.js +30 -49
- package/lib/esm/base/MutableProps/index.js.map +1 -1
- package/lib/esm/base/Plugin/index.js +13 -35
- package/lib/esm/base/Plugin/index.js.map +1 -1
- package/lib/esm/components/AnimationFrame/index.js +55 -98
- package/lib/esm/components/AnimationFrame/index.js.map +1 -1
- package/lib/esm/components/BaseTimeline/index.js +41 -88
- package/lib/esm/components/BaseTimeline/index.js.map +1 -1
- package/lib/esm/components/Ctx2D/index.js +82 -150
- package/lib/esm/components/Ctx2D/index.js.map +1 -1
- package/lib/esm/components/Ctx2DPrerender/index.js +20 -54
- package/lib/esm/components/Ctx2DPrerender/index.js.map +1 -1
- package/lib/esm/components/CustomCursor/index.js +149 -216
- package/lib/esm/components/CustomCursor/index.js.map +1 -1
- package/lib/esm/components/DraggerBase/index.js +98 -164
- package/lib/esm/components/DraggerBase/index.js.map +1 -1
- package/lib/esm/components/DraggerDirection/index.js +10 -42
- package/lib/esm/components/DraggerDirection/index.js.map +1 -1
- package/lib/esm/components/DraggerMove/index.js +42 -83
- package/lib/esm/components/DraggerMove/index.js.map +1 -1
- package/lib/esm/components/Preloader/index.js +77 -135
- package/lib/esm/components/Preloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/index.js +112 -190
- package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js +9 -10
- package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadImage.js +3 -3
- package/lib/esm/components/ProgressPreloader/utils/preloadImage.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js +2 -2
- package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js.map +1 -1
- package/lib/esm/components/ScrollBar/Bar/index.js +90 -136
- package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/esm/components/ScrollBar/index.js +70 -118
- package/lib/esm/components/ScrollBar/index.js.map +1 -1
- package/lib/esm/components/ScrollView/index.js +103 -154
- package/lib/esm/components/ScrollView/index.js.map +1 -1
- package/lib/esm/components/SectionScrollProgress/index.js +95 -170
- package/lib/esm/components/SectionScrollProgress/index.js.map +1 -1
- package/lib/esm/components/SmoothScroll/AnimatonFrame.js +20 -37
- package/lib/esm/components/SmoothScroll/AnimatonFrame.js.map +1 -1
- package/lib/esm/components/SmoothScroll/Elements.js +42 -59
- package/lib/esm/components/SmoothScroll/Elements.js.map +1 -1
- package/lib/esm/components/SmoothScroll/index.js +205 -304
- package/lib/esm/components/SmoothScroll/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollDragPlugin/index.js +48 -86
- package/lib/esm/components/SmoothScrollDragPlugin/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js +34 -70
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js.map +1 -1
- package/lib/esm/components/SplitText/index.js +117 -177
- package/lib/esm/components/SplitText/index.js.map +1 -1
- package/lib/esm/components/Timeline/index.js +45 -88
- package/lib/esm/components/Timeline/index.js.map +1 -1
- package/lib/esm/utils/common/mergeWithoutArrays.js +1 -1
- package/lib/esm/utils/common/mergeWithoutArrays.js.map +1 -1
- package/lib/esm/utils/common/normalizedTimeoutCallback.js +3 -3
- package/lib/esm/utils/common/normalizedTimeoutCallback.js.map +1 -1
- package/lib/esm/utils/common/pickObjectProps.js +2 -2
- package/lib/esm/utils/common/pickObjectProps.js.map +1 -1
- package/lib/esm/utils/common/times.js +2 -2
- package/lib/esm/utils/common/times.js.map +1 -1
- package/lib/esm/utils/common/uid.js +3 -4
- package/lib/esm/utils/common/uid.js.map +1 -1
- package/lib/esm/utils/image/load.js +15 -26
- package/lib/esm/utils/image/load.js.map +1 -1
- package/lib/esm/utils/image/pathsToProps.js +5 -5
- package/lib/esm/utils/image/pathsToProps.js.map +1 -1
- package/lib/esm/utils/image/sizesToSrcSet.js +5 -5
- package/lib/esm/utils/image/sizesToSrcSet.js.map +1 -1
- package/lib/esm/utils/internal/fetchWebpSupport.js +3 -3
- package/lib/esm/utils/internal/fetchWebpSupport.js.map +1 -1
- package/lib/esm/utils/internal/getDeviceInfo.js +7 -7
- package/lib/esm/utils/internal/getDeviceInfo.js.map +1 -1
- package/lib/esm/utils/internal/onResize.js +13 -16
- package/lib/esm/utils/internal/onResize.js.map +1 -1
- package/lib/esm/utils/math/clamp.js +1 -2
- package/lib/esm/utils/math/clamp.js.map +1 -1
- package/lib/esm/utils/math/clampScope.js +1 -3
- package/lib/esm/utils/math/clampScope.js.map +1 -1
- package/lib/esm/utils/math/easing.js +1 -5
- package/lib/esm/utils/math/easing.js.map +1 -1
- package/lib/esm/utils/math/inScope.js +1 -2
- package/lib/esm/utils/math/inScope.js.map +1 -1
- package/lib/esm/utils/math/lerp.js +3 -4
- package/lib/esm/utils/math/lerp.js.map +1 -1
- package/lib/esm/utils/math/normalizeNestedScope.js +1 -1
- package/lib/esm/utils/math/normalizeNestedScope.js.map +1 -1
- package/lib/esm/utils/math/scoped.js +2 -3
- package/lib/esm/utils/math/scoped.js.map +1 -1
- package/lib/esm/utils/math/spreadScope.js +5 -5
- package/lib/esm/utils/math/spreadScope.js.map +1 -1
- package/lib/esm/utils/math/wrap.js +2 -2
- package/lib/esm/utils/math/wrap.js.map +1 -1
- package/lib/esm/utils/scroll/getScrollValues.js +5 -6
- package/lib/esm/utils/scroll/getScrollValues.js.map +1 -1
- package/lib/esm/utils/scroll/onScroll.js +20 -23
- package/lib/esm/utils/scroll/onScroll.js.map +1 -1
- package/lib/esm/utils/scroll/scrollTo.js +10 -12
- package/lib/esm/utils/scroll/scrollTo.js.map +1 -1
- package/lib/esm/utils/scroll/scrollToElement.js +8 -19
- package/lib/esm/utils/scroll/scrollToElement.js.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/esm/vevet.js +1 -1
- package/lib/esm/vevet.js.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/version.ts +1 -1
|
@@ -1,84 +1,43 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
1
|
import { Component as ComponentClass } from '../../base/Component';
|
|
28
2
|
/**
|
|
29
3
|
* Launch an animation frame with a certain FPS
|
|
30
4
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
5
|
+
export class AnimationFrame extends ComponentClass {
|
|
6
|
+
_getDefaultProps() {
|
|
7
|
+
return Object.assign(Object.assign({}, super._getDefaultProps()), { fps: 'auto', autoFpsFrames: 50, isEnabled: false });
|
|
8
|
+
}
|
|
9
|
+
get isPlaying() {
|
|
10
|
+
return this._isPlaying;
|
|
11
|
+
}
|
|
12
|
+
/** Computed real time fps */
|
|
13
|
+
get computedFPS() {
|
|
14
|
+
return this._computedFPS;
|
|
15
|
+
}
|
|
16
|
+
/** Coefficient of standard fps (60) divided by computed fps */
|
|
17
|
+
get easeMultiplier() {
|
|
18
|
+
return 60 / this.computedFPS;
|
|
19
|
+
}
|
|
20
|
+
constructor(initialProps, canInit = true) {
|
|
21
|
+
super(initialProps, false);
|
|
22
|
+
this._isPlaying = false;
|
|
23
|
+
this._frame = null;
|
|
24
|
+
this._frameIndex = -1;
|
|
25
|
+
this._firstFrameTime = null;
|
|
26
|
+
this._lastFrameTime = null;
|
|
27
|
+
this._frameDurations = [];
|
|
28
|
+
this._computedFPS = this.props.fps !== 'auto' ? this.props.fps : 60;
|
|
43
29
|
if (canInit) {
|
|
44
|
-
|
|
30
|
+
this.init();
|
|
45
31
|
}
|
|
46
|
-
return _this;
|
|
47
32
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
Object.defineProperty(AnimationFrame.prototype, "isPlaying", {
|
|
52
|
-
get: function () {
|
|
53
|
-
return this._isPlaying;
|
|
54
|
-
},
|
|
55
|
-
enumerable: false,
|
|
56
|
-
configurable: true
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(AnimationFrame.prototype, "computedFPS", {
|
|
59
|
-
/** Computed real time fps */
|
|
60
|
-
get: function () {
|
|
61
|
-
return this._computedFPS;
|
|
62
|
-
},
|
|
63
|
-
enumerable: false,
|
|
64
|
-
configurable: true
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(AnimationFrame.prototype, "easeMultiplier", {
|
|
67
|
-
/** Coefficient of standard fps (60) divided by computed fps */
|
|
68
|
-
get: function () {
|
|
69
|
-
return 60 / this.computedFPS;
|
|
70
|
-
},
|
|
71
|
-
enumerable: false,
|
|
72
|
-
configurable: true
|
|
73
|
-
});
|
|
74
|
-
AnimationFrame.prototype._init = function () {
|
|
75
|
-
_super.prototype._init.call(this);
|
|
33
|
+
_init() {
|
|
34
|
+
super._init();
|
|
76
35
|
if (this.props.isEnabled) {
|
|
77
36
|
this.play();
|
|
78
37
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
38
|
+
}
|
|
39
|
+
_onPropsMutate() {
|
|
40
|
+
super._onPropsMutate();
|
|
82
41
|
this._frameIndex = -1;
|
|
83
42
|
this._firstFrameTime = null;
|
|
84
43
|
this._lastFrameTime = null;
|
|
@@ -88,9 +47,9 @@ var AnimationFrame = /** @class */ (function (_super) {
|
|
|
88
47
|
else {
|
|
89
48
|
this._pause();
|
|
90
49
|
}
|
|
91
|
-
}
|
|
50
|
+
}
|
|
92
51
|
/** Play animation */
|
|
93
|
-
|
|
52
|
+
play() {
|
|
94
53
|
if (this.isDestroyed) {
|
|
95
54
|
return;
|
|
96
55
|
}
|
|
@@ -98,9 +57,9 @@ var AnimationFrame = /** @class */ (function (_super) {
|
|
|
98
57
|
return;
|
|
99
58
|
}
|
|
100
59
|
this.changeProps({ isEnabled: true });
|
|
101
|
-
}
|
|
60
|
+
}
|
|
102
61
|
/** Play animation */
|
|
103
|
-
|
|
62
|
+
_play() {
|
|
104
63
|
if (this.isPlaying) {
|
|
105
64
|
return;
|
|
106
65
|
}
|
|
@@ -108,16 +67,16 @@ var AnimationFrame = /** @class */ (function (_super) {
|
|
|
108
67
|
this.callbacks.tbt('play', undefined);
|
|
109
68
|
this.callbacks.tbt('toggle', undefined);
|
|
110
69
|
this._frame = window.requestAnimationFrame(this._animate.bind(this));
|
|
111
|
-
}
|
|
70
|
+
}
|
|
112
71
|
/** Pause animation */
|
|
113
|
-
|
|
72
|
+
pause() {
|
|
114
73
|
if (!this.props.isEnabled) {
|
|
115
74
|
return;
|
|
116
75
|
}
|
|
117
76
|
this.changeProps({ isEnabled: false });
|
|
118
|
-
}
|
|
77
|
+
}
|
|
119
78
|
/** Pause animation */
|
|
120
|
-
|
|
79
|
+
_pause() {
|
|
121
80
|
if (!this.isPlaying) {
|
|
122
81
|
return;
|
|
123
82
|
}
|
|
@@ -128,21 +87,21 @@ var AnimationFrame = /** @class */ (function (_super) {
|
|
|
128
87
|
this._isPlaying = false;
|
|
129
88
|
this.callbacks.tbt('pause', undefined);
|
|
130
89
|
this.callbacks.tbt('toggle', undefined);
|
|
131
|
-
}
|
|
90
|
+
}
|
|
132
91
|
/** Launch the animation frame */
|
|
133
|
-
|
|
92
|
+
_animate() {
|
|
134
93
|
if (!this._isPlaying) {
|
|
135
94
|
return;
|
|
136
95
|
}
|
|
137
96
|
this._frame = window.requestAnimationFrame(this._animate.bind(this));
|
|
138
97
|
// update time
|
|
139
|
-
|
|
98
|
+
const startTime = +new Date();
|
|
140
99
|
if (this._firstFrameTime === null) {
|
|
141
100
|
this._firstFrameTime = startTime;
|
|
142
101
|
}
|
|
143
102
|
// calculate frame index
|
|
144
|
-
|
|
145
|
-
|
|
103
|
+
const minFrameDuration = this.props.fps === 'auto' ? 1 : 1000 / this.props.fps;
|
|
104
|
+
const newFrameIndex = Math.floor((startTime - this._firstFrameTime) / minFrameDuration);
|
|
146
105
|
// break if frame index the same
|
|
147
106
|
if (newFrameIndex <= this._frameIndex) {
|
|
148
107
|
return;
|
|
@@ -155,11 +114,11 @@ var AnimationFrame = /** @class */ (function (_super) {
|
|
|
155
114
|
this.callbacks.tbt('frame', undefined);
|
|
156
115
|
// update vars
|
|
157
116
|
this._lastFrameTime = startTime;
|
|
158
|
-
}
|
|
117
|
+
}
|
|
159
118
|
/** Compute real-time FPS */
|
|
160
|
-
|
|
119
|
+
_computeFPS(startTime) {
|
|
161
120
|
var _a;
|
|
162
|
-
|
|
121
|
+
const lastFrameDuration = startTime - ((_a = this._lastFrameTime) !== null && _a !== void 0 ? _a : startTime);
|
|
163
122
|
// skip frames that seem not real
|
|
164
123
|
if (lastFrameDuration <= 0 || lastFrameDuration > 250) {
|
|
165
124
|
return;
|
|
@@ -168,20 +127,18 @@ var AnimationFrame = /** @class */ (function (_super) {
|
|
|
168
127
|
if (this._frameDurations.length < this.props.autoFpsFrames) {
|
|
169
128
|
return;
|
|
170
129
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
130
|
+
const totalFramesDuration = this._frameDurations.reduce((prev, curr) => prev + curr);
|
|
131
|
+
const approximateFrameDuration = totalFramesDuration / this._frameDurations.length;
|
|
132
|
+
const computedFPS = Math.floor(1000 / approximateFrameDuration);
|
|
133
|
+
const normalizedFPS = Math.round(computedFPS / 10) * 10;
|
|
175
134
|
this._computedFPS = normalizedFPS;
|
|
176
135
|
// clear durations
|
|
177
136
|
this._frameDurations = [];
|
|
178
|
-
}
|
|
137
|
+
}
|
|
179
138
|
/** Destroy the animation frame */
|
|
180
|
-
|
|
139
|
+
_destroy() {
|
|
181
140
|
this.pause();
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
}(ComponentClass));
|
|
186
|
-
export { AnimationFrame };
|
|
141
|
+
super._destroy();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
187
144
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/AnimationFrame/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/AnimationFrame/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAK/D;;GAEG;AACH,MAAM,OAAO,cAIX,SAAQ,cAA4D;IAC1D,gBAAgB;QACxB,uCACK,KAAK,CAAC,gBAAgB,EAAE,KAC3B,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,EAAE,EACjB,SAAS,EAAE,KAAK,IAChB;IACJ,CAAC;IAKD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAoBD,6BAA6B;IAC7B,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,+DAA+D;IAC/D,IAAI,cAAc;QAChB,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;IAC/B,CAAC;IAED,YAAY,YAA4C,EAAE,OAAO,GAAG,IAAI;QACtE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAE3B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAEpE,IAAI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CAAC,KAAK,EAAE,CAAC;QAEb,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
1
|
import { Component as ComponentClass } from '../../base/Component';
|
|
28
2
|
import { clampScope, easing } from '../../utils/math';
|
|
29
3
|
import { uid } from '../../utils/common';
|
|
@@ -31,91 +5,70 @@ import { uid } from '../../utils/common';
|
|
|
31
5
|
* `BaseTimeline` is the base class for the `Timeline` itself.
|
|
32
6
|
* The difference between the coponents is that `BaseTimeline` has no autonomous animation.
|
|
33
7
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
8
|
+
export class BaseTimeline extends ComponentClass {
|
|
9
|
+
_getDefaultProps() {
|
|
10
|
+
return Object.assign(Object.assign({}, super._getDefaultProps()), { easing: this.app.props.easing, scope: [0, 1], hasNestedEasingProgress: false });
|
|
11
|
+
}
|
|
12
|
+
/** Global timeline progress */
|
|
13
|
+
get progress() {
|
|
14
|
+
return this._progress;
|
|
15
|
+
}
|
|
16
|
+
set progress(val) {
|
|
17
|
+
this._progress = val;
|
|
18
|
+
this._handleProgressUpdate();
|
|
19
|
+
}
|
|
20
|
+
/** Easing progress */
|
|
21
|
+
get easing() {
|
|
22
|
+
return this._easing;
|
|
23
|
+
}
|
|
24
|
+
constructor(initialProps, canInit = true) {
|
|
25
|
+
super(initialProps, false);
|
|
39
26
|
// set default vars
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
this._progress = 0;
|
|
28
|
+
this._easing = 0;
|
|
29
|
+
this._nestedTimelines = [];
|
|
43
30
|
if (canInit) {
|
|
44
|
-
|
|
31
|
+
this.init();
|
|
45
32
|
}
|
|
46
|
-
return _this;
|
|
47
33
|
}
|
|
48
|
-
BaseTimeline.prototype._getDefaultProps = function () {
|
|
49
|
-
return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { easing: this.app.props.easing, scope: [0, 1], hasNestedEasingProgress: false });
|
|
50
|
-
};
|
|
51
|
-
Object.defineProperty(BaseTimeline.prototype, "progress", {
|
|
52
|
-
/** Global timeline progress */
|
|
53
|
-
get: function () {
|
|
54
|
-
return this._progress;
|
|
55
|
-
},
|
|
56
|
-
set: function (val) {
|
|
57
|
-
this._progress = val;
|
|
58
|
-
this._handleProgressUpdate();
|
|
59
|
-
},
|
|
60
|
-
enumerable: false,
|
|
61
|
-
configurable: true
|
|
62
|
-
});
|
|
63
|
-
Object.defineProperty(BaseTimeline.prototype, "easing", {
|
|
64
|
-
/** Easing progress */
|
|
65
|
-
get: function () {
|
|
66
|
-
return this._easing;
|
|
67
|
-
},
|
|
68
|
-
enumerable: false,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
34
|
/** Add a nested timeline */
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this._nestedTimelines.push({ id: id, timeline: timeline });
|
|
35
|
+
addNestedTimeline(timeline) {
|
|
36
|
+
const id = uid();
|
|
37
|
+
this._nestedTimelines.push({ id, timeline });
|
|
76
38
|
return {
|
|
77
|
-
remove:
|
|
78
|
-
|
|
79
|
-
var nestedTimelineId = _a.id;
|
|
80
|
-
return nestedTimelineId !== id;
|
|
81
|
-
});
|
|
39
|
+
remove: () => {
|
|
40
|
+
this._nestedTimelines = this._nestedTimelines.filter(({ id: nestedTimelineId }) => nestedTimelineId !== id);
|
|
82
41
|
},
|
|
83
42
|
};
|
|
84
|
-
}
|
|
43
|
+
}
|
|
85
44
|
/** Handle progress event */
|
|
86
|
-
|
|
45
|
+
_handleProgressUpdate() {
|
|
87
46
|
this._easing = easing(this._progress, this.props.easing);
|
|
88
47
|
this.callbacks.tbt('progress', {
|
|
89
48
|
progress: this._progress,
|
|
90
49
|
easing: this._easing,
|
|
91
50
|
});
|
|
92
51
|
this._renderNestedTimelines();
|
|
93
|
-
}
|
|
52
|
+
}
|
|
94
53
|
/** Render nested timelines */
|
|
95
|
-
|
|
96
|
-
|
|
54
|
+
_renderNestedTimelines() {
|
|
55
|
+
const { length } = this._nestedTimelines;
|
|
97
56
|
if (length === 0) {
|
|
98
57
|
return;
|
|
99
58
|
}
|
|
100
|
-
|
|
59
|
+
const progressForNestedTimeline = this.props.hasNestedEasingProgress
|
|
101
60
|
? this.easing
|
|
102
61
|
: this.progress;
|
|
103
|
-
this._nestedTimelines.forEach(
|
|
104
|
-
|
|
105
|
-
var timelineProgress = clampScope(progressForNestedTimeline, timeline.props.nestedScope, [0, 1]);
|
|
62
|
+
this._nestedTimelines.forEach(({ timeline }) => {
|
|
63
|
+
const timelineProgress = clampScope(progressForNestedTimeline, timeline.props.nestedScope, [0, 1]);
|
|
106
64
|
// eslint-disable-next-line no-param-reassign
|
|
107
65
|
timeline.progress = timelineProgress;
|
|
108
66
|
});
|
|
109
|
-
}
|
|
67
|
+
}
|
|
110
68
|
/** Destroy the module */
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._nestedTimelines.forEach(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
return BaseTimeline;
|
|
119
|
-
}(ComponentClass));
|
|
120
|
-
export { BaseTimeline };
|
|
69
|
+
_destroy() {
|
|
70
|
+
super._destroy();
|
|
71
|
+
this._nestedTimelines.forEach(({ timeline }) => timeline.destroy());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
121
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/BaseTimeline/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/BaseTimeline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAIrC;;;GAGG;AACH,MAAM,OAAO,YAIX,SAAQ,cAA4D;IAC1D,gBAAgB;QACxB,uCACK,KAAK,CAAC,gBAAgB,EAAE,KAC3B,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAC7B,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EACb,uBAAuB,EAAE,KAAK,IAC9B;IACJ,CAAC;IAKD,+BAA+B;IAC/B,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,QAAQ,CAAC,GAAW;QACtB,IAAI,CAAC,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