vevet 2.0.1-dev.23 → 2.0.1-dev.28
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/build/cdn/index.js +1 -1
- package/build/cjs/components/animation-frame/AnimationFrame.js +1 -1
- package/build/cjs/components/scroll/scrollable/ScrollView.js +57 -28
- package/build/cjs/components/scroll/scrollbar/Bar.js +4 -4
- package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +5 -5
- package/build/cjs/components/text/SplitText.js +5 -1
- package/build/cjs/components/timeline/StaticTimeline.js +3 -3
- package/build/cjs/components/timeline/Timeline.js +2 -2
- package/build/cjs/utils/math/clamp.js +16 -0
- package/build/cjs/utils/math/clampScope.js +16 -0
- package/build/cjs/utils/math/inScope.js +10 -0
- package/build/cjs/utils/math/index.js +11 -7
- package/build/cjs/utils/math/scoped.js +18 -0
- package/build/cjs/utils/math/spreadScope.js +18 -0
- package/build/es/components/animation-frame/AnimationFrame.js +2 -2
- package/build/es/components/scroll/scrollable/ScrollView.js +57 -28
- package/build/es/components/scroll/scrollbar/Bar.js +4 -4
- package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +5 -5
- package/build/es/components/text/SplitText.js +5 -1
- package/build/es/components/timeline/StaticTimeline.js +3 -3
- package/build/es/components/timeline/Timeline.js +2 -2
- package/build/es/utils/math/clamp.js +12 -0
- package/build/es/utils/math/clampScope.js +8 -0
- package/build/es/utils/math/inScope.js +6 -0
- package/build/es/utils/math/index.js +6 -4
- package/build/es/utils/math/scoped.js +14 -0
- package/build/es/utils/math/spreadScope.js +15 -0
- package/build/types/components/scroll/scrollable/ScrollView.d.ts +11 -3
- package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
- package/build/types/components/text/SplitText.d.ts.map +1 -1
- package/build/types/utils/math/clamp.d.ts +5 -0
- package/build/types/utils/math/clamp.d.ts.map +1 -0
- package/build/types/utils/math/clampScope.d.ts +5 -0
- package/build/types/utils/math/clampScope.d.ts.map +1 -0
- package/build/types/utils/math/inScope.d.ts +5 -0
- package/build/types/utils/math/inScope.d.ts.map +1 -0
- package/build/types/utils/math/index.d.ts +6 -4
- package/build/types/utils/math/index.d.ts.map +1 -1
- package/build/types/utils/math/scoped.d.ts +12 -0
- package/build/types/utils/math/scoped.d.ts.map +1 -0
- package/build/types/utils/math/spreadScope.d.ts +5 -0
- package/build/types/utils/math/spreadScope.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/ts/components/animation-frame/AnimationFrame.ts +2 -2
- package/src/ts/components/scroll/scrollable/ScrollView.ts +74 -35
- package/src/ts/components/scroll/scrollbar/Bar.ts +4 -4
- package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +5 -5
- package/src/ts/components/text/SplitText.ts +5 -1
- package/src/ts/components/timeline/StaticTimeline.ts +4 -4
- package/src/ts/components/timeline/Timeline.ts +2 -2
- package/src/ts/utils/math/{boundVal.ts → clamp.ts} +3 -3
- package/src/ts/utils/math/clampScope.ts +16 -0
- package/src/ts/utils/math/inScope.ts +9 -0
- package/src/ts/utils/math/index.ts +10 -6
- package/src/ts/utils/math/scoped.ts +17 -0
- package/src/ts/utils/math/{spreadScopeProgress.ts → spreadScope.ts} +2 -2
- package/src/ts/utils/math/scopeProgress.ts +0 -23
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ScrollEventsBase } from './ScrollEventsBase';
|
|
2
2
|
import onScroll from '../../../utils/listeners/onScroll';
|
|
3
3
|
import { intersectionObserverSupported } from '../../../utils/listeners';
|
|
4
|
-
import
|
|
4
|
+
import clamp from '../../../utils/math/clamp';
|
|
5
5
|
import timeoutCallback from '../../../utils/common/timeoutCallback';
|
|
6
6
|
/**
|
|
7
7
|
* Elements into viewport
|
|
@@ -10,7 +10,8 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
10
10
|
constructor(initialProp, init = true) {
|
|
11
11
|
super(initialProp, false);
|
|
12
12
|
this._scrollEvent = undefined;
|
|
13
|
-
this.
|
|
13
|
+
this._intersectionObserverIn = undefined;
|
|
14
|
+
this._intersectionObserverOut = undefined;
|
|
14
15
|
this._firstStart = true;
|
|
15
16
|
this._elements = [...this.prop.elements];
|
|
16
17
|
// initialize the class
|
|
@@ -67,17 +68,27 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
67
68
|
? 0 : scrollContainerBounding.width * (1 - this.prop.threshold) * -1;
|
|
68
69
|
const yMargin = this._firstStart
|
|
69
70
|
? 0 : scrollContainerBounding.height * (1 - this.prop.threshold) * -1;
|
|
70
|
-
// create intersection
|
|
71
|
-
this.
|
|
71
|
+
// create intersection observers
|
|
72
|
+
this._intersectionObserverIn = new IntersectionObserver(this._handleIntersectionObserverIn.bind(this), {
|
|
72
73
|
root: this.intersectionRoot,
|
|
73
74
|
threshold: 0,
|
|
74
75
|
rootMargin: `0px ${xMargin}px ${yMargin}px 0px`,
|
|
75
76
|
});
|
|
76
|
-
// add elements
|
|
77
77
|
this.elements.forEach((el) => {
|
|
78
78
|
var _a;
|
|
79
|
-
(_a = this.
|
|
79
|
+
(_a = this._intersectionObserverIn) === null || _a === void 0 ? void 0 : _a.observe(el);
|
|
80
80
|
});
|
|
81
|
+
if (this.prop.states === 'inout') {
|
|
82
|
+
this._intersectionObserverOut = new IntersectionObserver(this._handleIntersectionObserverOut.bind(this), {
|
|
83
|
+
root: this.intersectionRoot,
|
|
84
|
+
threshold: 0,
|
|
85
|
+
rootMargin: '0px 0px 0px 0px',
|
|
86
|
+
});
|
|
87
|
+
this.elements.forEach((el) => {
|
|
88
|
+
var _a;
|
|
89
|
+
(_a = this._intersectionObserverOut) === null || _a === void 0 ? void 0 : _a.observe(el);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
else {
|
|
83
94
|
// set scroll bounding events
|
|
@@ -91,21 +102,22 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
91
102
|
* Remove View events: scroll or intersection
|
|
92
103
|
*/
|
|
93
104
|
_removeViewEvents() {
|
|
105
|
+
var _a, _b;
|
|
94
106
|
// remove scroll events
|
|
95
107
|
if (this._scrollEvent) {
|
|
96
108
|
this._scrollEvent.remove();
|
|
97
109
|
this._scrollEvent = undefined;
|
|
98
110
|
}
|
|
99
|
-
// destroy intersection
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
// destroy intersection observers
|
|
112
|
+
(_a = this._intersectionObserverIn) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
113
|
+
this._intersectionObserverIn = undefined;
|
|
114
|
+
(_b = this._intersectionObserverOut) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
115
|
+
this._intersectionObserverOut = undefined;
|
|
104
116
|
}
|
|
105
117
|
/**
|
|
106
118
|
* Event on IntersectionObserver
|
|
107
119
|
*/
|
|
108
|
-
|
|
120
|
+
_handleIntersectionObserverIn(data) {
|
|
109
121
|
const parentBounding = this._firstStart ? this.scrollContainerBounding : false;
|
|
110
122
|
for (let index = 0; index < data.length; index += 1) {
|
|
111
123
|
const entry = data[index];
|
|
@@ -113,7 +125,9 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
113
125
|
if (this._firstStart && !!parentBounding && entry.isIntersecting) {
|
|
114
126
|
delay = this._elementInViewportData(entry.target, parentBounding).delay;
|
|
115
127
|
}
|
|
116
|
-
|
|
128
|
+
if (entry.isIntersecting) {
|
|
129
|
+
this._handleInOut(entry.target, entry.isIntersecting, delay);
|
|
130
|
+
}
|
|
117
131
|
}
|
|
118
132
|
this._processUnusedElements();
|
|
119
133
|
// change states
|
|
@@ -122,6 +136,17 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
122
136
|
this.resize();
|
|
123
137
|
}
|
|
124
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Event on IntersectionObserver
|
|
141
|
+
*/
|
|
142
|
+
_handleIntersectionObserverOut(data) {
|
|
143
|
+
for (let index = 0; index < data.length; index += 1) {
|
|
144
|
+
const entry = data[index];
|
|
145
|
+
if (!entry.isIntersecting) {
|
|
146
|
+
this._handleInOut(entry.target, entry.isIntersecting, 0);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
125
150
|
/**
|
|
126
151
|
* Event on Scroll
|
|
127
152
|
*/
|
|
@@ -144,7 +169,9 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
144
169
|
const el = this.elements[index];
|
|
145
170
|
const elData = this._elementInViewportData(el, scrollContainerBounding);
|
|
146
171
|
const delay = elData.isIntersecting ? elData.delay : 0;
|
|
147
|
-
|
|
172
|
+
if (typeof elData.isIntersecting === 'boolean') {
|
|
173
|
+
this._handleInOut(el, elData.isIntersecting, delay);
|
|
174
|
+
}
|
|
148
175
|
}
|
|
149
176
|
this._processUnusedElements();
|
|
150
177
|
// change states
|
|
@@ -160,7 +187,7 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
160
187
|
const threshold = this._firstStart ? 1 : propThreshold;
|
|
161
188
|
const bounding = el.getBoundingClientRect();
|
|
162
189
|
// check if the element is intersecting
|
|
163
|
-
let isIntersecting
|
|
190
|
+
let isIntersecting;
|
|
164
191
|
if (bounding.top < parentBounding.top + parentBounding.height * threshold
|
|
165
192
|
&& bounding.left < parentBounding.left + parentBounding.width * threshold) {
|
|
166
193
|
if (states === 'in') {
|
|
@@ -174,11 +201,15 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
174
201
|
isIntersecting = true;
|
|
175
202
|
}
|
|
176
203
|
}
|
|
204
|
+
else if (bounding.top > parentBounding.top + parentBounding.height
|
|
205
|
+
|| bounding.left > parentBounding.left + parentBounding.width) {
|
|
206
|
+
isIntersecting = false;
|
|
207
|
+
}
|
|
177
208
|
// calculate delay only if it is enabled & calculations
|
|
178
209
|
// are done for the first time
|
|
179
210
|
let delay = 0;
|
|
180
211
|
if (!!useDelay && this._firstStart) {
|
|
181
|
-
const progress =
|
|
212
|
+
const progress = clamp(useDelay.dir === 'x'
|
|
182
213
|
? (bounding.left - parentBounding.left) / parentBounding.width
|
|
183
214
|
: (bounding.top - parentBounding.top) / parentBounding.height, [0, 1]);
|
|
184
215
|
delay = progress * useDelay.max;
|
|
@@ -228,9 +259,9 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
228
259
|
// remove unused elements
|
|
229
260
|
const elementsToRemove = this._elements.filter((el) => el.scrollViewIn);
|
|
230
261
|
elementsToRemove.forEach((el) => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
262
|
+
var _a, _b;
|
|
263
|
+
(_a = this._intersectionObserverIn) === null || _a === void 0 ? void 0 : _a.unobserve(el);
|
|
264
|
+
(_b = this._intersectionObserverOut) === null || _b === void 0 ? void 0 : _b.unobserve(el);
|
|
234
265
|
});
|
|
235
266
|
this._elements = this._elements.filter((el) => !el.scrollViewIn);
|
|
236
267
|
}
|
|
@@ -238,12 +269,12 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
238
269
|
* Add a view element
|
|
239
270
|
*/
|
|
240
271
|
addElement(element) {
|
|
272
|
+
var _a, _b;
|
|
241
273
|
const viewEl = element;
|
|
242
274
|
viewEl.scrollViewIn = undefined;
|
|
243
275
|
this._elements.push(element);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
276
|
+
(_a = this._intersectionObserverIn) === null || _a === void 0 ? void 0 : _a.observe(element);
|
|
277
|
+
(_b = this._intersectionObserverOut) === null || _b === void 0 ? void 0 : _b.observe(element);
|
|
247
278
|
if (this.prop.enabled) {
|
|
248
279
|
this.seekBounding();
|
|
249
280
|
}
|
|
@@ -257,21 +288,19 @@ export class ScrollView extends ScrollEventsBase {
|
|
|
257
288
|
* Remove a view element
|
|
258
289
|
*/
|
|
259
290
|
removeElement(element) {
|
|
291
|
+
var _a, _b;
|
|
260
292
|
const viewEl = element;
|
|
261
293
|
viewEl.scrollViewIn = undefined;
|
|
262
294
|
this._elements = this._elements.filter((el) => el !== element);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
295
|
+
(_a = this._intersectionObserverIn) === null || _a === void 0 ? void 0 : _a.unobserve(element);
|
|
296
|
+
(_b = this._intersectionObserverOut) === null || _b === void 0 ? void 0 : _b.unobserve(element);
|
|
266
297
|
}
|
|
267
298
|
/**
|
|
268
299
|
* Remove all view elements
|
|
269
300
|
*/
|
|
270
301
|
removeElements() {
|
|
271
302
|
this._elements.forEach((el) => {
|
|
272
|
-
|
|
273
|
-
this._intersectionObserver.unobserve(el);
|
|
274
|
-
}
|
|
303
|
+
this.removeElement(el);
|
|
275
304
|
});
|
|
276
305
|
this._elements = [];
|
|
277
306
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addEventListener, createElement } from 'vevet-dom';
|
|
2
2
|
import onScroll from '../../../utils/listeners/onScroll';
|
|
3
|
-
import
|
|
3
|
+
import clamp from '../../../utils/math/clamp';
|
|
4
4
|
import { DraggerMove } from '../../dragger/DraggerMove';
|
|
5
5
|
import { SmoothScroll } from '../smooth-scroll/SmoothScroll';
|
|
6
6
|
export default class Bar {
|
|
@@ -215,7 +215,7 @@ export default class Bar {
|
|
|
215
215
|
*/
|
|
216
216
|
_renderThumb() {
|
|
217
217
|
// calculate progress
|
|
218
|
-
const progress =
|
|
218
|
+
const progress = clamp(this._scrollVal / this.scrollLine, [0, 1]);
|
|
219
219
|
// calculate transforms
|
|
220
220
|
const x = this.isX ? (this._outerWidth - this._thumbWidth) * progress : 0;
|
|
221
221
|
const y = this.isY ? (this._outerHeight - this._thumbHeight) * progress : 0;
|
|
@@ -234,11 +234,11 @@ export default class Bar {
|
|
|
234
234
|
// calculate thumb sizes
|
|
235
235
|
if (this.prop.autoSize) {
|
|
236
236
|
if (this.isX) {
|
|
237
|
-
const barSize =
|
|
237
|
+
const barSize = clamp(this._outerWidth / (this.scrollWidth / (this.scrollWidth - scrollLine)), [minSize, Infinity]);
|
|
238
238
|
thumb.style.width = `${barSize}px`;
|
|
239
239
|
}
|
|
240
240
|
else {
|
|
241
|
-
const barSize =
|
|
241
|
+
const barSize = clamp(this._outerHeight / (this.scrollHeight / (this.scrollHeight - scrollLine)), [minSize, Infinity]);
|
|
242
242
|
thumb.style.height = `${barSize}px`;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -2,7 +2,7 @@ import { selectAll, selectOne, isElement, createElement, } from 'vevet-dom';
|
|
|
2
2
|
import normalizeWheel from 'normalize-wheel';
|
|
3
3
|
import { Component } from '../../../base/Component';
|
|
4
4
|
import { AnimationFrame } from '../../animation-frame/AnimationFrame';
|
|
5
|
-
import
|
|
5
|
+
import clamp from '../../../utils/math/clamp';
|
|
6
6
|
import { lerp } from '../../../utils/math';
|
|
7
7
|
/**
|
|
8
8
|
* Create smooth scrolling.
|
|
@@ -90,7 +90,7 @@ export class SmoothScroll extends Component {
|
|
|
90
90
|
? -this.prop.overscroll.max : 0;
|
|
91
91
|
const max = this.maxScrollableWidth
|
|
92
92
|
+ (!!this.prop.overscroll && this.prop.isHorizontal ? this.prop.overscroll.max : 0);
|
|
93
|
-
this._targetLeft =
|
|
93
|
+
this._targetLeft = clamp(val, [min, max]);
|
|
94
94
|
}
|
|
95
95
|
get targetLeftBound() {
|
|
96
96
|
return this._targetLeft;
|
|
@@ -110,7 +110,7 @@ export class SmoothScroll extends Component {
|
|
|
110
110
|
? -this.prop.overscroll.max : 0;
|
|
111
111
|
const max = this.maxScrollableHeight
|
|
112
112
|
+ (!!this.prop.overscroll && !this.prop.isHorizontal ? this.prop.overscroll.max : 0);
|
|
113
|
-
this._targetTop =
|
|
113
|
+
this._targetTop = clamp(val, [min, max]);
|
|
114
114
|
}
|
|
115
115
|
get targetTopBound() {
|
|
116
116
|
return this._targetTop;
|
|
@@ -209,8 +209,8 @@ export class SmoothScroll extends Component {
|
|
|
209
209
|
// get sizes
|
|
210
210
|
this._clientWidth = outer.clientWidth;
|
|
211
211
|
this._clientHeight = outer.clientHeight;
|
|
212
|
-
this._scrollWidth =
|
|
213
|
-
this._scrollHeight =
|
|
212
|
+
this._scrollWidth = clamp(container.clientWidth, [this.clientWidth, Infinity]);
|
|
213
|
+
this._scrollHeight = clamp(container.clientHeight, [this.clientHeight, Infinity]);
|
|
214
214
|
// force instant change
|
|
215
215
|
// it means that after resizing, scrolling will be instantaneous for a while
|
|
216
216
|
if (native) {
|
|
@@ -19,8 +19,12 @@ export class SplitText extends Component {
|
|
|
19
19
|
}
|
|
20
20
|
// get initial text
|
|
21
21
|
this._initHTML = this._container.innerHTML;
|
|
22
|
-
|
|
22
|
+
const innerText = this._container.innerText.trim() || this._container.innerHTML.trim();
|
|
23
|
+
this._initText = innerText || 'no rendered text';
|
|
23
24
|
this._initText = this._initText.replace(/\s+\n/gm, '\n');
|
|
25
|
+
this._initText = this._initText.replace(/<br>/gm, String.fromCharCode(10));
|
|
26
|
+
this._initText = this._initText.replace(/<br\/>/gm, String.fromCharCode(10));
|
|
27
|
+
this._initText = this._initText.replace(/<br \/>/gm, String.fromCharCode(10));
|
|
24
28
|
// set default vars
|
|
25
29
|
this._isPrimarySplit = false;
|
|
26
30
|
this._letters = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import easingProgress from 'easing-progress';
|
|
2
2
|
import { Component } from '../../base/Component';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import scoped from '../../utils/math/scoped';
|
|
4
|
+
import clamp from '../../utils/math/clamp';
|
|
5
5
|
/**
|
|
6
6
|
* StaticTimeline is the base class for Timeline itself.
|
|
7
7
|
* The difference between the coponents is that StaticTimeline has no animation:
|
|
@@ -75,7 +75,7 @@ export class StaticTimeline extends Component {
|
|
|
75
75
|
for (let index = 0, l = length; index < l; index += 1) {
|
|
76
76
|
const tm = this._nestedTimelines[index];
|
|
77
77
|
// calculate progress of this very timeline
|
|
78
|
-
const tmProgress =
|
|
78
|
+
const tmProgress = clamp(scoped(progressForNested, tm.prop.nestedScope), [0, 1]);
|
|
79
79
|
tm.progress = tmProgress;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StaticTimeline } from './StaticTimeline';
|
|
2
|
-
import
|
|
2
|
+
import clamp from '../../utils/math/clamp';
|
|
3
3
|
/**
|
|
4
4
|
* Timeline is an animation helper.
|
|
5
5
|
*/
|
|
@@ -102,7 +102,7 @@ export class Timeline extends StaticTimeline {
|
|
|
102
102
|
this._animationFrameLastTime = currentTime;
|
|
103
103
|
// calculate current progress
|
|
104
104
|
const progressIterator = frameDiff / this.prop.duration / (isReversed ? -1 : 1);
|
|
105
|
-
const progressTarget =
|
|
105
|
+
const progressTarget = clamp(this.progress + progressIterator, [0, 1]);
|
|
106
106
|
this.progress = progressTarget;
|
|
107
107
|
// end animation
|
|
108
108
|
if ((progressTarget === 1 && !isReversed)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import scoped from './scoped';
|
|
2
|
+
import clamp from './clamp';
|
|
3
|
+
/**
|
|
4
|
+
* Get progress relatively to the scope and clamp it within two points
|
|
5
|
+
*/
|
|
6
|
+
export default function clampScoped(val, scope = [0, 1], clampScope = [0, 1]) {
|
|
7
|
+
return clamp(scoped(val, scope), clampScope);
|
|
8
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import clamp from './clamp';
|
|
2
2
|
import lerp from './lerp';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import scoped from './scoped';
|
|
4
|
+
import spreadScope from './spreadScope';
|
|
5
|
+
import inScope from './inScope';
|
|
6
|
+
import clampScope from './clampScope';
|
|
5
7
|
import wrap from './wrap';
|
|
6
|
-
export {
|
|
8
|
+
export { clamp, lerp, scoped, spreadScope, inScope, clampScope, wrap, };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get progress relatively to the scope.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* scope(.35, [0, 1]);
|
|
7
|
+
* // => .5
|
|
8
|
+
* scope(.35, [.25, 1]);
|
|
9
|
+
* // => .133
|
|
10
|
+
*/
|
|
11
|
+
export default function scoped(val, scopeValue = [0, 1]) {
|
|
12
|
+
const result = (val - scopeValue[0]) / (scopeValue[1] - scopeValue[0]);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distribute scope progress among a certain quantity of timelines.
|
|
3
|
+
*/
|
|
4
|
+
export default function spreadScope(quantity, shift) {
|
|
5
|
+
const timelines = [];
|
|
6
|
+
// duration for each element
|
|
7
|
+
const duration = 1 / (quantity - shift * (quantity - 1));
|
|
8
|
+
// calculate timelines
|
|
9
|
+
for (let index = 0; index < quantity; index += 1) {
|
|
10
|
+
const start = (duration * (1 - shift)) * index;
|
|
11
|
+
const end = start + duration;
|
|
12
|
+
timelines.push([start, end]);
|
|
13
|
+
}
|
|
14
|
+
return timelines;
|
|
15
|
+
}
|
|
@@ -78,9 +78,13 @@ export declare class ScrollView<StaticProp extends NScrollView.StaticProp = NScr
|
|
|
78
78
|
*/
|
|
79
79
|
protected _scrollEvent?: IRemovable;
|
|
80
80
|
/**
|
|
81
|
-
* Intersection observer
|
|
81
|
+
* Intersection observer - type IN
|
|
82
82
|
*/
|
|
83
|
-
protected
|
|
83
|
+
protected _intersectionObserverIn?: IntersectionObserver;
|
|
84
|
+
/**
|
|
85
|
+
* Intersection observer - type OUT
|
|
86
|
+
*/
|
|
87
|
+
protected _intersectionObserverOut?: IntersectionObserver;
|
|
84
88
|
/**
|
|
85
89
|
* If first start
|
|
86
90
|
*/
|
|
@@ -109,7 +113,11 @@ export declare class ScrollView<StaticProp extends NScrollView.StaticProp = NScr
|
|
|
109
113
|
/**
|
|
110
114
|
* Event on IntersectionObserver
|
|
111
115
|
*/
|
|
112
|
-
protected
|
|
116
|
+
protected _handleIntersectionObserverIn(data: IntersectionObserverEntry[]): void;
|
|
117
|
+
/**
|
|
118
|
+
* Event on IntersectionObserver
|
|
119
|
+
*/
|
|
120
|
+
protected _handleIntersectionObserverOut(data: IntersectionObserverEntry[]): void;
|
|
113
121
|
/**
|
|
114
122
|
* Event on Scroll
|
|
115
123
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../../../../src/ts/components/scroll/scrollable/ScrollView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAQlE,yBAAiB,WAAW,CAAC;IAEzB;;OAEG;IACH,UAAiB,UAAW,SAAQ,iBAAiB,CAAC,UAAU;QAC5D;;;;;WAKG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;;WAGG;QACH,MAAM,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC;QACxB;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB;;;WAGG;QACH,QAAQ,CAAC,EAAE,KAAK,GAAG;YACf,GAAG,EAAE,MAAM,CAAC;YACZ,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;SAClB,CAAC;QACF;;;WAGG;QACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;KACrC;IAED;;OAEG;IACH,UAAiB,cAAe,SAAQ,iBAAiB,CAAC,cAAc;KAAI;IAE5E;;OAEG;IACH,UAAiB,EAAG,SAAQ,OAAO;QAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;KAC1B;IAED;;OAEG;IACH,UAAiB,cAAe,SAAQ,iBAAiB,CAAC,cAAc;QACpE,IAAI,EAAE,EAAE,CAAC;QACT,KAAK,EAAE,EAAE,CAAC;KACb;CAEJ;AAID;;GAEG;AACH,qBAAa,UAAU,CACnB,UAAU,SAAS,WAAW,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,EAClE,cAAc,SAAS,WAAW,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,EAC9E,cAAc,SAAS,WAAW,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,CAChF,SAAQ,gBAAgB,CACtB,UAAU,EACV,cAAc,EACd,cAAc,CACjB;IACG,IAAI,MAAM,WAET;IAED,SAAS,CAAC,eAAe,CACrB,CAAC,SAAS,kBAAkB,CAAC,UAAU,GAAG,cAAc,CAAC,KACvD,CAAC;IAgBP;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC;IACpC;;OAEG;IACH,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../../../../src/ts/components/scroll/scrollable/ScrollView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAQlE,yBAAiB,WAAW,CAAC;IAEzB;;OAEG;IACH,UAAiB,UAAW,SAAQ,iBAAiB,CAAC,UAAU;QAC5D;;;;;WAKG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;;WAGG;QACH,MAAM,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC;QACxB;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB;;;WAGG;QACH,QAAQ,CAAC,EAAE,KAAK,GAAG;YACf,GAAG,EAAE,MAAM,CAAC;YACZ,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;SAClB,CAAC;QACF;;;WAGG;QACH,u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,SAAS,CAAC,cAAc;IA2CxB;;OAEG;IACH,SAAS,CAAC,iBAAiB;IAa3B;;OAEG;IACH,SAAS,CAAC,6BAA6B,CACnC,IAAI,EAAE,yBAAyB,EAAE;IAyBrC;;OAEG;IACH,SAAS,CAAC,8BAA8B,CACpC,IAAI,EAAE,yBAAyB,EAAE;IAcrC;;OAEG;IACH,SAAS,CAAC,aAAa;IAIvB;;;OAGG;IACI,YAAY;IA0BnB;;OAEG;IACH,SAAS,CAAC,sBAAsB,CAC5B,EAAE,EAAE,OAAO,EACX,cAAc,EAAE,iBAAiB,CAAC,YAAY;;;;IAgDlD;;OAEG;IACH,SAAS,CAAC,YAAY,CAClB,EAAE,EAAE,WAAW,CAAC,EAAE,EAClB,UAAU,EAAE,OAAO,EACnB,KAAK,SAAI;IAgCb;;OAEG;IACH,SAAS,CAAC,sBAAsB;IAchC;;OAEG;IACI,UAAU,CACb,OAAO,EAAE,OAAO,GACjB,UAAU;IAgBb;;OAEG;IACI,aAAa,CAChB,OAAO,EAAE,OAAO;IASpB;;OAEG;IACI,cAAc;IASrB;;OAEG;IACH,SAAS,CAAC,QAAQ;CAIrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitText.d.ts","sourceRoot":"","sources":["../../../../src/ts/components/text/SplitText.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,yBAAiB,UAAU,CAAC;IAExB;;OAEG;IACH,UAAiB,UAAW,SAAQ,UAAU,CAAC,UAAU;QACrD;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7B;;;WAGG;QACH,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB;;;WAGG;QACH,WAAW,CAAC,EAAE,OAAO,C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,UAAU,CAAC,IAAI,EAAE,CAAC;IAEpC,IAAI,KAAK,sBAER;IACD,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;gBAKhC,WAAW,CAAC,EAAE,CAAC,UAAU,GAAG,cAAc,CAAC,EAC3C,IAAI,UAAO;IAsCf,SAAS,CAAC,UAAU;IAcpB;;OAEG;IACI,SAAS;IAmBhB;;OAEG;IACH,SAAS,CAAC,eAAe;IAiEzB;;OAEG;IACH,SAAS,CAAC,YAAY;IAYtB;;OAEG;IACH,SAAS,CAAC,YAAY;IActB;;OAEG;IACH,SAAS,CAAC,iBAAiB;IAkC3B;;OAEG;IACH,SAAS,CAAC,eAAe;IA8DzB;;OAEG;IACH,SAAS,CAAC,YAAY;IAYtB;;OAEG;IACH,SAAS,CAAC,QAAQ;CASrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/clamp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,WAAS,UASjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clampScope.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/clampScope.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,KAAK,WAAS,EACd,UAAU,WAAS,UAMtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inScope.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/inScope.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC3B,GAAG,EAAE,MAAM,EACX,UAAU,WAAS,WAGtB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import clamp from './clamp';
|
|
2
2
|
import lerp from './lerp';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import scoped from './scoped';
|
|
4
|
+
import spreadScope from './spreadScope';
|
|
5
|
+
import inScope from './inScope';
|
|
6
|
+
import clampScope from './clampScope';
|
|
5
7
|
import wrap from './wrap';
|
|
6
|
-
export {
|
|
8
|
+
export { clamp, lerp, scoped, spreadScope, inScope, clampScope, wrap, };
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,OAAO,EACH,KAAK,EACL,IAAI,EACJ,MAAM,EACN,WAAW,EACX,OAAO,EACP,UAAU,EACV,IAAI,GACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get progress relatively to the scope.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* scope(.35, [0, 1]);
|
|
7
|
+
* // => .5
|
|
8
|
+
* scope(.35, [.25, 1]);
|
|
9
|
+
* // => .133
|
|
10
|
+
*/
|
|
11
|
+
export default function scoped(val: number, scopeValue?: number[]): number;
|
|
12
|
+
//# sourceMappingURL=scoped.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/scoped.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC1B,GAAG,EAAE,MAAM,EACX,UAAU,WAAS,UAItB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spreadScope.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/math/spreadScope.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,cAYhB"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, NComponent } from '../../base/Component';
|
|
2
|
-
import {
|
|
2
|
+
import { clamp } from '../../utils/math';
|
|
3
3
|
import { RequiredModuleProp } from '../../utils/types/utility';
|
|
4
4
|
|
|
5
5
|
|
|
@@ -237,7 +237,7 @@ export class AnimationFrame <
|
|
|
237
237
|
|
|
238
238
|
// calculate real fps
|
|
239
239
|
const timeDiff = currentTime - this._prevFrameTime;
|
|
240
|
-
const realFPS =
|
|
240
|
+
const realFPS = clamp(
|
|
241
241
|
timeDiff === 0 ? 1000 / 60 : Math.floor(1000 / timeDiff),
|
|
242
242
|
[1, Infinity],
|
|
243
243
|
);
|