vevet 2.0.1-dev.9 → 2.0.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/build/cdn/index.js +1 -1
- package/build/cjs/app/Application.js +8 -8
- package/build/cjs/app/events/PageLoad.js +3 -3
- package/build/cjs/app/events/Viewport.js +5 -5
- package/build/cjs/base/Callbacks.js +3 -3
- package/build/cjs/base/Module.js +16 -7
- package/build/cjs/base/MutableProp.js +10 -10
- package/build/cjs/components/animation-frame/AnimationFrame.js +1 -1
- package/build/cjs/components/canvas/Ctx2D.js +7 -3
- package/build/cjs/components/canvas/Ctx2DPrerender.js +17 -3
- package/build/cjs/components/cursor/CustomCursor.js +12 -12
- package/build/cjs/components/dragger/Dragger.js +8 -8
- package/build/cjs/components/dragger/DraggerMove.js +2 -2
- package/build/cjs/components/loading/Preloader.js +5 -5
- package/build/cjs/components/loading/ProgressPreloader.js +17 -5
- package/build/cjs/components/page/Page.js +37 -9
- package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +2 -2
- package/build/cjs/components/scroll/scrollable/ScrollEventsBase.js +1 -1
- package/build/cjs/components/scroll/scrollable/ScrollView.js +133 -73
- package/build/cjs/components/scroll/scrollbar/Bar.js +18 -15
- package/build/cjs/components/scroll/scrollbar/ScrollBar.js +9 -7
- package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +26 -22
- package/build/cjs/components/text/SplitText.js +34 -12
- package/build/cjs/components/timeline/StaticTimeline.js +4 -4
- package/build/cjs/components/timeline/Timeline.js +2 -2
- package/build/cjs/handlers/wheel/WheelHandler.js +4 -4
- package/build/cjs/utils/common/mergeWithoutArrays.js +1 -1
- package/build/cjs/utils/common/randID.js +2 -2
- package/build/cjs/utils/listeners/onScroll.js +66 -28
- package/build/cjs/utils/math/{boundVal.js → clamp.js} +3 -3
- 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 +13 -7
- package/build/cjs/utils/math/scoped.js +18 -0
- package/build/cjs/utils/math/{spreadScopeProgress.js → spreadScope.js} +2 -2
- package/build/cjs/utils/math/wrap.js +13 -0
- package/build/es/base/Module.js +2 -4
- package/build/es/components/animation-frame/AnimationFrame.js +2 -2
- package/build/es/components/canvas/Ctx2D.js +6 -2
- package/build/es/components/canvas/Ctx2DPrerender.js +16 -2
- package/build/es/components/loading/ProgressPreloader.js +14 -2
- package/build/es/components/page/Page.js +32 -8
- package/build/es/components/scroll/scrollable/ScrollView.js +112 -62
- package/build/es/components/scroll/scrollbar/Bar.js +9 -6
- package/build/es/components/scroll/scrollbar/ScrollBar.js +3 -1
- package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +13 -9
- package/build/es/components/text/SplitText.js +25 -3
- package/build/es/components/timeline/StaticTimeline.js +3 -3
- package/build/es/components/timeline/Timeline.js +2 -2
- package/build/es/utils/listeners/onScroll.js +65 -28
- package/build/es/utils/math/{boundVal.js → clamp.js} +2 -2
- 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 +7 -4
- package/build/es/utils/math/scoped.js +14 -0
- package/build/es/utils/math/{spreadScopeProgress.js → spreadScope.js} +1 -1
- package/build/es/utils/math/wrap.js +10 -0
- package/build/types/base/Module.d.ts.map +1 -1
- package/build/types/components/canvas/Ctx2D.d.ts +9 -0
- package/build/types/components/canvas/Ctx2D.d.ts.map +1 -1
- package/build/types/components/canvas/Ctx2DPrerender.d.ts +1 -1
- package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -1
- package/build/types/components/loading/ProgressPreloader.d.ts +7 -0
- package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -1
- package/build/types/components/page/Page.d.ts +2 -0
- package/build/types/components/page/Page.d.ts.map +1 -1
- package/build/types/components/scroll/scrollable/ScrollView.d.ts +40 -14
- package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
- package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -1
- package/build/types/components/scroll/scrollbar/ScrollBar.d.ts +4 -0
- package/build/types/components/scroll/scrollbar/ScrollBar.d.ts.map +1 -1
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts +4 -0
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -1
- package/build/types/components/text/SplitText.d.ts +10 -0
- package/build/types/components/text/SplitText.d.ts.map +1 -1
- package/build/types/utils/listeners/onScroll.d.ts +10 -6
- package/build/types/utils/listeners/onScroll.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 +7 -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/build/types/utils/math/wrap.d.ts +5 -0
- package/build/types/utils/math/wrap.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/ts/base/Module.ts +5 -4
- package/src/ts/components/animation-frame/AnimationFrame.ts +2 -2
- package/src/ts/components/canvas/Ctx2D.ts +16 -1
- package/src/ts/components/canvas/Ctx2DPrerender.ts +19 -6
- package/src/ts/components/loading/ProgressPreloader.ts +21 -2
- package/src/ts/components/page/Page.ts +34 -8
- package/src/ts/components/scroll/scrollable/ScrollView.ts +155 -86
- package/src/ts/components/scroll/scrollbar/Bar.ts +9 -6
- package/src/ts/components/scroll/scrollbar/ScrollBar.ts +7 -0
- package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +17 -8
- package/src/ts/components/text/SplitText.ts +38 -2
- package/src/ts/components/timeline/StaticTimeline.ts +4 -4
- package/src/ts/components/timeline/Timeline.ts +2 -2
- package/src/ts/utils/listeners/onScroll.ts +101 -38
- 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 +12 -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/wrap.ts +18 -0
- package/build/cjs/components/scroll/custom-scroll/CustomScroll.js +0 -517
- package/build/cjs/components/split-text/SplitText.js +0 -233
- package/build/cjs/utils/math/scopeProgress.js +0 -25
- package/build/es/components/scroll/custom-scroll/CustomScroll.js +0 -486
- package/build/es/components/split-text/SplitText.js +0 -199
- package/build/es/utils/math/scopeProgress.js +0 -22
- package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts +0 -322
- package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts.map +0 -1
- package/build/types/components/split-text/SplitText.d.ts +0 -118
- package/build/types/components/split-text/SplitText.d.ts.map +0 -1
- package/build/types/utils/math/boundVal.d.ts +0 -5
- package/build/types/utils/math/boundVal.d.ts.map +0 -1
- package/build/types/utils/math/scopeProgress.d.ts +0 -20
- package/build/types/utils/math/scopeProgress.d.ts.map +0 -1
- package/build/types/utils/math/spreadScopeProgress.d.ts +0 -5
- package/build/types/utils/math/spreadScopeProgress.d.ts.map +0 -1
- package/src/ts/utils/math/scopeProgress.ts +0 -23
|
@@ -45,7 +45,7 @@ var ScrollBar = /** @class */ (function (_super) {
|
|
|
45
45
|
var _a = _this.prop, autoHide = _a.autoHide, autoSize = _a.autoSize, minSize = _a.minSize, optimizeCalculations = _a.optimizeCalculations, isDraggable = _a.isDraggable, draggableScrollBehavior = _a.draggableScrollBehavior;
|
|
46
46
|
// get container
|
|
47
47
|
if (typeof _this.prop.container === 'string') {
|
|
48
|
-
var el = vevet_dom_1.selectOne(_this.prop.container);
|
|
48
|
+
var el = (0, vevet_dom_1.selectOne)(_this.prop.container);
|
|
49
49
|
if (el) {
|
|
50
50
|
_this._container = el;
|
|
51
51
|
}
|
|
@@ -60,12 +60,12 @@ var ScrollBar = /** @class */ (function (_super) {
|
|
|
60
60
|
if (_this.container instanceof Element) {
|
|
61
61
|
var parentElement = _this.container.parentElement;
|
|
62
62
|
if (parentElement) {
|
|
63
|
-
_this._scrollWrapper = vevet_dom_1.createElement('div');
|
|
63
|
+
_this._scrollWrapper = (0, vevet_dom_1.createElement)('div');
|
|
64
64
|
_this._scrollWrapper.style.position = 'relative';
|
|
65
65
|
_this._scrollWrapper.style.display = 'inline-block';
|
|
66
66
|
parentElement.insertBefore(_this._scrollWrapper, _this.container);
|
|
67
67
|
_this._scrollWrapper.appendChild(_this.container);
|
|
68
|
-
_this._scrollWrapper.classList.add(_this.prefix
|
|
68
|
+
_this._scrollWrapper.classList.add("".concat(_this.prefix, "-wrapper"));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
// create bars
|
|
@@ -83,7 +83,7 @@ var ScrollBar = /** @class */ (function (_super) {
|
|
|
83
83
|
_this._xBar = new Bar_1.default(__assign({ dir: 'x' }, barMainProp));
|
|
84
84
|
_this._yBar = new Bar_1.default(__assign({ dir: 'y' }, barMainProp));
|
|
85
85
|
// add styles
|
|
86
|
-
_this.scrollableElement.classList.add(_this.prefix
|
|
86
|
+
_this.scrollableElement.classList.add("".concat(_this.prefix, "-parent"));
|
|
87
87
|
// initialize the class
|
|
88
88
|
if (init) {
|
|
89
89
|
_this.init();
|
|
@@ -91,11 +91,11 @@ var ScrollBar = /** @class */ (function (_super) {
|
|
|
91
91
|
return _this;
|
|
92
92
|
}
|
|
93
93
|
ScrollBar.prototype._getDefaultProp = function () {
|
|
94
|
-
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: window, domParent: false, draggable: true, autoSize: true, autoHide: true, minSize: 50, optimizeCalculations: false, isDraggable: true, draggableScrollBehavior: 'smooth' });
|
|
94
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: window, domParent: false, draggable: true, autoSize: true, autoHide: true, minSize: 50, optimizeCalculations: false, resizeTimeout: 0, isDraggable: true, draggableScrollBehavior: 'smooth' });
|
|
95
95
|
};
|
|
96
96
|
Object.defineProperty(ScrollBar.prototype, "prefix", {
|
|
97
97
|
get: function () {
|
|
98
|
-
return this._app.prefix
|
|
98
|
+
return "".concat(this._app.prefix, "scrollbar");
|
|
99
99
|
},
|
|
100
100
|
enumerable: false,
|
|
101
101
|
configurable: true
|
|
@@ -167,6 +167,8 @@ var ScrollBar = /** @class */ (function (_super) {
|
|
|
167
167
|
else {
|
|
168
168
|
this.addViewportCallback('', function () {
|
|
169
169
|
_this.resize();
|
|
170
|
+
}, {
|
|
171
|
+
timeout: this.prop.resizeTimeout,
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
174
|
this.resize();
|
|
@@ -199,7 +201,7 @@ var ScrollBar = /** @class */ (function (_super) {
|
|
|
199
201
|
this._scrollWrapper.remove();
|
|
200
202
|
}
|
|
201
203
|
// reset styles
|
|
202
|
-
this.scrollableElement.classList.remove(this.prefix
|
|
204
|
+
this.scrollableElement.classList.remove("".concat(this.prefix, "-parent"));
|
|
203
205
|
};
|
|
204
206
|
return ScrollBar;
|
|
205
207
|
}(Component_1.Component));
|
|
@@ -34,7 +34,7 @@ var vevet_dom_1 = require("vevet-dom");
|
|
|
34
34
|
var normalize_wheel_1 = __importDefault(require("normalize-wheel"));
|
|
35
35
|
var Component_1 = require("../../../base/Component");
|
|
36
36
|
var AnimationFrame_1 = require("../../animation-frame/AnimationFrame");
|
|
37
|
-
var
|
|
37
|
+
var clamp_1 = __importDefault(require("../../../utils/math/clamp"));
|
|
38
38
|
var math_1 = require("../../../utils/math");
|
|
39
39
|
/**
|
|
40
40
|
* Create smooth scrolling.
|
|
@@ -59,20 +59,20 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
59
59
|
_this._outerAnimationFrameEvent = undefined;
|
|
60
60
|
_this._currentFPS = 60;
|
|
61
61
|
// get outer elements
|
|
62
|
-
_this._outer = vevet_dom_1.selectOne(selectors.outer);
|
|
62
|
+
_this._outer = (0, vevet_dom_1.selectOne)(selectors.outer);
|
|
63
63
|
if (!(_this._outer instanceof HTMLElement)) {
|
|
64
|
-
throw new Error(selectors.outer
|
|
64
|
+
throw new Error("".concat(selectors.outer, " is not a HTMLElement"));
|
|
65
65
|
}
|
|
66
66
|
_this._outer.classList.add(_this.prefix);
|
|
67
67
|
// get or create container
|
|
68
|
-
var existingContainer = vevet_dom_1.selectOne("."
|
|
69
|
-
if (vevet_dom_1.isElement(existingContainer)) {
|
|
68
|
+
var existingContainer = (0, vevet_dom_1.selectOne)(".".concat(_this.prefix, "__container"), _this.outer);
|
|
69
|
+
if ((0, vevet_dom_1.isElement)(existingContainer)) {
|
|
70
70
|
_this._container = existingContainer;
|
|
71
71
|
_this._containerExists = true;
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
_this._container = vevet_dom_1.createElement('div', {
|
|
75
|
-
class: _this.prefix
|
|
74
|
+
_this._container = (0, vevet_dom_1.createElement)('div', {
|
|
75
|
+
class: "".concat(_this.prefix, "__container"),
|
|
76
76
|
parent: _this.outer,
|
|
77
77
|
children: Array.from(_this.outer.children),
|
|
78
78
|
});
|
|
@@ -80,16 +80,18 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
80
80
|
}
|
|
81
81
|
// get scrollable elements
|
|
82
82
|
if (selectors.elements) {
|
|
83
|
-
_this._elements = Array.from(vevet_dom_1.selectAll(selectors.elements, _this._outer));
|
|
83
|
+
_this._elements = Array.from((0, vevet_dom_1.selectAll)(selectors.elements, _this._outer));
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
86
|
_this._elements = [_this._container];
|
|
87
87
|
}
|
|
88
88
|
_this._elementsLength = _this._elements.length;
|
|
89
89
|
// add will-change
|
|
90
|
-
_this.
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
if (_this.prop.useWillChange) {
|
|
91
|
+
_this._elements.forEach(function (el) {
|
|
92
|
+
el.style.willChange = 'transform';
|
|
93
|
+
});
|
|
94
|
+
}
|
|
93
95
|
// initialize the class
|
|
94
96
|
if (init) {
|
|
95
97
|
_this.init();
|
|
@@ -98,7 +100,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
98
100
|
}
|
|
99
101
|
Object.defineProperty(SmoothScroll.prototype, "prefix", {
|
|
100
102
|
get: function () {
|
|
101
|
-
return this._app.prefix
|
|
103
|
+
return "".concat(this._app.prefix, "smooth-scroll");
|
|
102
104
|
},
|
|
103
105
|
enumerable: false,
|
|
104
106
|
configurable: true
|
|
@@ -147,7 +149,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
147
149
|
? -this.prop.overscroll.max : 0;
|
|
148
150
|
var max = this.maxScrollableWidth
|
|
149
151
|
+ (!!this.prop.overscroll && this.prop.isHorizontal ? this.prop.overscroll.max : 0);
|
|
150
|
-
this._targetLeft =
|
|
152
|
+
this._targetLeft = (0, clamp_1.default)(val, [min, max]);
|
|
151
153
|
},
|
|
152
154
|
enumerable: false,
|
|
153
155
|
configurable: true
|
|
@@ -175,7 +177,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
175
177
|
? -this.prop.overscroll.max : 0;
|
|
176
178
|
var max = this.maxScrollableHeight
|
|
177
179
|
+ (!!this.prop.overscroll && !this.prop.isHorizontal ? this.prop.overscroll.max : 0);
|
|
178
|
-
this._targetTop =
|
|
180
|
+
this._targetTop = (0, clamp_1.default)(val, [min, max]);
|
|
179
181
|
},
|
|
180
182
|
enumerable: false,
|
|
181
183
|
configurable: true
|
|
@@ -254,9 +256,9 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
254
256
|
});
|
|
255
257
|
SmoothScroll.prototype._getDefaultProp = function () {
|
|
256
258
|
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { selectors: {
|
|
257
|
-
outer: "#"
|
|
259
|
+
outer: "#".concat(this.prefix),
|
|
258
260
|
elements: false,
|
|
259
|
-
}, enabled: true, animationFrame: false, recalculateSizes: true, useWheel: true, autoStop: true, isHorizontal: false, stopPropagation: true, useWillChange: true, render: {
|
|
261
|
+
}, enabled: true, animationFrame: false, recalculateSizes: true, resizeTimeout: 0, useWheel: true, autoStop: true, isHorizontal: false, stopPropagation: true, useWillChange: true, render: {
|
|
260
262
|
lerp: 0.1,
|
|
261
263
|
lerpToFixed: 2,
|
|
262
264
|
approximation: 0.1,
|
|
@@ -278,6 +280,8 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
278
280
|
this.resize();
|
|
279
281
|
this.addViewportCallback('', function () {
|
|
280
282
|
_this.resize(true);
|
|
283
|
+
}, {
|
|
284
|
+
timeout: this.prop.resizeTimeout,
|
|
281
285
|
});
|
|
282
286
|
// wheel
|
|
283
287
|
this.addEventListeners(this.outer, 'wheel', function (e) {
|
|
@@ -308,8 +312,8 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
308
312
|
// get sizes
|
|
309
313
|
this._clientWidth = outer.clientWidth;
|
|
310
314
|
this._clientHeight = outer.clientHeight;
|
|
311
|
-
this._scrollWidth =
|
|
312
|
-
this._scrollHeight =
|
|
315
|
+
this._scrollWidth = (0, clamp_1.default)(container.clientWidth, [this.clientWidth, Infinity]);
|
|
316
|
+
this._scrollHeight = (0, clamp_1.default)(container.clientHeight, [this.clientHeight, Infinity]);
|
|
313
317
|
// force instant change
|
|
314
318
|
// it means that after resizing, scrolling will be instantaneous for a while
|
|
315
319
|
if (native) {
|
|
@@ -353,7 +357,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
353
357
|
el.smoothScrollLeft = this.scrollLeft;
|
|
354
358
|
el.smoothScrollTop = this.scrollTop;
|
|
355
359
|
// update easing
|
|
356
|
-
var easingAttr = el.getAttribute(this.prefix
|
|
360
|
+
var easingAttr = el.getAttribute("".concat(this.prefix, "-ease"));
|
|
357
361
|
if (easingAttr) {
|
|
358
362
|
try {
|
|
359
363
|
el.smoothScrollLerpEase = parseFloat(easingAttr);
|
|
@@ -384,7 +388,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
384
388
|
evt.preventDefault();
|
|
385
389
|
}
|
|
386
390
|
// get normalized delta
|
|
387
|
-
var delta = normalize_wheel_1.default(evt);
|
|
391
|
+
var delta = (0, normalize_wheel_1.default)(evt);
|
|
388
392
|
// set new scroll targets
|
|
389
393
|
this.targetLeftBound += prop.isHorizontal ? delta.pixelY : delta.pixelX;
|
|
390
394
|
this.targetTopBound += prop.isHorizontal ? delta.pixelX : delta.pixelY;
|
|
@@ -525,7 +529,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
525
529
|
if (ease === void 0) { ease = this._getLerpEase(); }
|
|
526
530
|
var _a = this.prop.render, lerpToFixed = _a.lerpToFixed, approximation = _a.approximation;
|
|
527
531
|
var currentEase = this._instant ? 1 : ease;
|
|
528
|
-
var val = math_1.lerp(current, target, currentEase, approximation);
|
|
532
|
+
var val = (0, math_1.lerp)(current, target, currentEase, approximation);
|
|
529
533
|
// round the values
|
|
530
534
|
if (typeof lerpToFixed === 'number') {
|
|
531
535
|
var fixed = Math.round(Math.abs(lerpToFixed));
|
|
@@ -555,7 +559,7 @@ var SmoothScroll = /** @class */ (function (_super) {
|
|
|
555
559
|
var x = -el.smoothScrollLeft;
|
|
556
560
|
var y = -el.smoothScrollTop;
|
|
557
561
|
// set styles
|
|
558
|
-
el.style.transform = "matrix3d(1,0,0.00,0,0.00,1,0.00,0,0,0,1,0, "
|
|
562
|
+
el.style.transform = "matrix3d(1,0,0.00,0,0.00,1,0.00,0,0,0,1,0, ".concat(x, ", ").concat(y, ", 0,1)");
|
|
559
563
|
}
|
|
560
564
|
};
|
|
561
565
|
// LIKE NATIVE SCROLL
|
|
@@ -39,7 +39,7 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
39
39
|
var _this = _super.call(this, initialProp, false) || this;
|
|
40
40
|
// get text container
|
|
41
41
|
if (_this.prop.container) {
|
|
42
|
-
var container = vevet_dom_1.selectOne(_this.prop.container);
|
|
42
|
+
var container = (0, vevet_dom_1.selectOne)(_this.prop.container);
|
|
43
43
|
if (container instanceof HTMLElement) {
|
|
44
44
|
_this._container = container;
|
|
45
45
|
}
|
|
@@ -50,8 +50,12 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
50
50
|
}
|
|
51
51
|
// get initial text
|
|
52
52
|
_this._initHTML = _this._container.innerHTML;
|
|
53
|
-
|
|
53
|
+
var innerText = _this._container.innerText.trim() || _this._container.innerHTML.trim();
|
|
54
|
+
_this._initText = innerText || 'no rendered text';
|
|
54
55
|
_this._initText = _this._initText.replace(/\s+\n/gm, '\n');
|
|
56
|
+
_this._initText = _this._initText.replace(/<br>/gm, String.fromCharCode(10));
|
|
57
|
+
_this._initText = _this._initText.replace(/<br\/>/gm, String.fromCharCode(10));
|
|
58
|
+
_this._initText = _this._initText.replace(/<br \/>/gm, String.fromCharCode(10));
|
|
55
59
|
// set default vars
|
|
56
60
|
_this._isPrimarySplit = false;
|
|
57
61
|
_this._letters = [];
|
|
@@ -64,11 +68,11 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
64
68
|
return _this;
|
|
65
69
|
}
|
|
66
70
|
SplitText.prototype._getDefaultProp = function () {
|
|
67
|
-
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: "#"
|
|
71
|
+
return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: "#".concat(this.prefix), appendLetters: true, appendLines: false, viewportTarget: '', resizeTimeout: 0 });
|
|
68
72
|
};
|
|
69
73
|
Object.defineProperty(SplitText.prototype, "prefix", {
|
|
70
74
|
get: function () {
|
|
71
|
-
return this._app.prefix
|
|
75
|
+
return "".concat(this._app.prefix, "split-text");
|
|
72
76
|
},
|
|
73
77
|
enumerable: false,
|
|
74
78
|
configurable: true
|
|
@@ -110,8 +114,10 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
110
114
|
// split the text
|
|
111
115
|
this.splitText();
|
|
112
116
|
if (this.prop.appendLines) {
|
|
113
|
-
this.addViewportCallback(
|
|
117
|
+
this.addViewportCallback(this.prop.viewportTarget, function () {
|
|
114
118
|
_this.splitText();
|
|
119
|
+
}, {
|
|
120
|
+
timeout: this.prop.resizeTimeout,
|
|
115
121
|
});
|
|
116
122
|
}
|
|
117
123
|
};
|
|
@@ -147,8 +153,8 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
147
153
|
var currentWord = _this._words[wordIndex] || {
|
|
148
154
|
content: '',
|
|
149
155
|
hasNewLine: false,
|
|
150
|
-
el: vevet_dom_1.createElement('span', {
|
|
151
|
-
class: _this.prefix
|
|
156
|
+
el: (0, vevet_dom_1.createElement)('span', {
|
|
157
|
+
class: "".concat(_this.prefix, "__word"),
|
|
152
158
|
}),
|
|
153
159
|
letters: [],
|
|
154
160
|
};
|
|
@@ -157,13 +163,14 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
157
163
|
// get type of the char
|
|
158
164
|
var charCode = char.charCodeAt(0);
|
|
159
165
|
var isWhitespace = charCode === 32 || charCode === 160;
|
|
166
|
+
var isSeparator = [45, 8208, 8211, 8212, 8722].includes(charCode);
|
|
160
167
|
var isNewLine = charCode === 10;
|
|
161
168
|
// add elements
|
|
162
169
|
if (isWhitespace) {
|
|
163
170
|
currentWord.whitespace = document.createTextNode(' ');
|
|
164
171
|
}
|
|
165
172
|
if (isNewLine) {
|
|
166
|
-
currentWord.br = vevet_dom_1.createElement('br');
|
|
173
|
+
currentWord.br = (0, vevet_dom_1.createElement)('br');
|
|
167
174
|
}
|
|
168
175
|
// update word states
|
|
169
176
|
currentWord.hasNewLine = isNewLine;
|
|
@@ -177,6 +184,21 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
177
184
|
if (!_this.prop.appendLetters) {
|
|
178
185
|
currentWord.el.innerHTML = currentWord.content;
|
|
179
186
|
}
|
|
187
|
+
// go to next word if needed
|
|
188
|
+
if (isSeparator) {
|
|
189
|
+
wordIndex += 1;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
// only filled words
|
|
193
|
+
this._words = this._words.filter(function (word, index) {
|
|
194
|
+
if (word.content.length === 0) {
|
|
195
|
+
if (index > 0) {
|
|
196
|
+
_this._words[index - 1].whitespace = word.whitespace;
|
|
197
|
+
_this._words[index - 1].br = word.br;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
180
202
|
});
|
|
181
203
|
};
|
|
182
204
|
/**
|
|
@@ -223,8 +245,8 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
223
245
|
var wordLetters = [];
|
|
224
246
|
chars.forEach(function (char) {
|
|
225
247
|
var letter = {
|
|
226
|
-
el: vevet_dom_1.createElement('span', {
|
|
227
|
-
class: _this.prefix
|
|
248
|
+
el: (0, vevet_dom_1.createElement)('span', {
|
|
249
|
+
class: "".concat(_this.prefix, "__letter"),
|
|
228
250
|
html: char,
|
|
229
251
|
}),
|
|
230
252
|
content: char,
|
|
@@ -270,8 +292,8 @@ var SplitText = /** @class */ (function (_super) {
|
|
|
270
292
|
// create new line
|
|
271
293
|
if (isNewLine) {
|
|
272
294
|
currentLine = {
|
|
273
|
-
el: vevet_dom_1.createElement('span', {
|
|
274
|
-
class: _this.prefix
|
|
295
|
+
el: (0, vevet_dom_1.createElement)('span', {
|
|
296
|
+
class: "".concat(_this.prefix, "__line"),
|
|
275
297
|
}),
|
|
276
298
|
content: '',
|
|
277
299
|
words: [],
|
|
@@ -32,8 +32,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.StaticTimeline = void 0;
|
|
33
33
|
var easing_progress_1 = __importDefault(require("easing-progress"));
|
|
34
34
|
var Component_1 = require("../../base/Component");
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var scoped_1 = __importDefault(require("../../utils/math/scoped"));
|
|
36
|
+
var clamp_1 = __importDefault(require("../../utils/math/clamp"));
|
|
37
37
|
/**
|
|
38
38
|
* StaticTimeline is the base class for Timeline itself.
|
|
39
39
|
* The difference between the coponents is that StaticTimeline has no animation:
|
|
@@ -95,7 +95,7 @@ var StaticTimeline = /** @class */ (function (_super) {
|
|
|
95
95
|
*/
|
|
96
96
|
StaticTimeline.prototype._handleProgress = function () {
|
|
97
97
|
// calculate easing progress
|
|
98
|
-
this._easing = easing_progress_1.default(this._progress, this.prop.easing);
|
|
98
|
+
this._easing = (0, easing_progress_1.default)(this._progress, this.prop.easing);
|
|
99
99
|
// launch progress events
|
|
100
100
|
this._callbacks.tbt('progress', {
|
|
101
101
|
progress: this._progress,
|
|
@@ -118,7 +118,7 @@ var StaticTimeline = /** @class */ (function (_super) {
|
|
|
118
118
|
for (var index = 0, l = length; index < l; index += 1) {
|
|
119
119
|
var tm = this._nestedTimelines[index];
|
|
120
120
|
// calculate progress of this very timeline
|
|
121
|
-
var tmProgress =
|
|
121
|
+
var tmProgress = (0, clamp_1.default)((0, scoped_1.default)(progressForNested, tm.prop.nestedScope), [0, 1]);
|
|
122
122
|
tm.progress = tmProgress;
|
|
123
123
|
}
|
|
124
124
|
};
|
|
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.Timeline = void 0;
|
|
33
33
|
var StaticTimeline_1 = require("./StaticTimeline");
|
|
34
|
-
var
|
|
34
|
+
var clamp_1 = __importDefault(require("../../utils/math/clamp"));
|
|
35
35
|
/**
|
|
36
36
|
* Timeline is an animation helper.
|
|
37
37
|
*/
|
|
@@ -149,7 +149,7 @@ var Timeline = /** @class */ (function (_super) {
|
|
|
149
149
|
this._animationFrameLastTime = currentTime;
|
|
150
150
|
// calculate current progress
|
|
151
151
|
var progressIterator = frameDiff / this.prop.duration / (isReversed ? -1 : 1);
|
|
152
|
-
var progressTarget =
|
|
152
|
+
var progressTarget = (0, clamp_1.default)(this.progress + progressIterator, [0, 1]);
|
|
153
153
|
this.progress = progressTarget;
|
|
154
154
|
// end animation
|
|
155
155
|
if ((progressTarget === 1 && !isReversed)
|
|
@@ -69,8 +69,8 @@ var WheelHandler = /** @class */ (function (_super) {
|
|
|
69
69
|
WheelHandler.prototype._setEvents = function () {
|
|
70
70
|
_super.prototype._setEvents.call(this);
|
|
71
71
|
if (!(this.container instanceof Window)) {
|
|
72
|
-
this._listeners.push(vevet_dom_1.addEventListener(this.container, 'mouseenter', this._handleMouseEnter.bind(this)));
|
|
73
|
-
this._listeners.push(vevet_dom_1.addEventListener(this.container, 'mouseleave', this._handleMouseLeave.bind(this)));
|
|
72
|
+
this._listeners.push((0, vevet_dom_1.addEventListener)(this.container, 'mouseenter', this._handleMouseEnter.bind(this)));
|
|
73
|
+
this._listeners.push((0, vevet_dom_1.addEventListener)(this.container, 'mouseleave', this._handleMouseLeave.bind(this)));
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
this._toggleWheelEvent();
|
|
@@ -118,7 +118,7 @@ var WheelHandler = /** @class */ (function (_super) {
|
|
|
118
118
|
clearTimeout(this._lockWheelTimeout);
|
|
119
119
|
}
|
|
120
120
|
// create a listener
|
|
121
|
-
this._wheelListener = vevet_dom_1.addEventListener(this.container, 'wheel',
|
|
121
|
+
this._wheelListener = (0, vevet_dom_1.addEventListener)(this.container, 'wheel',
|
|
122
122
|
// throttle(this._handleWheel.bind(this), 200),
|
|
123
123
|
this._handleWheel.bind(this));
|
|
124
124
|
};
|
|
@@ -156,7 +156,7 @@ var WheelHandler = /** @class */ (function (_super) {
|
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
// data
|
|
159
|
-
var delta = normalize_wheel_1.default(evt);
|
|
159
|
+
var delta = (0, normalize_wheel_1.default)(evt);
|
|
160
160
|
var threshold = this.prop.threshold;
|
|
161
161
|
// launch events
|
|
162
162
|
var eventFired = false;
|
|
@@ -9,7 +9,7 @@ var lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
|
|
|
9
9
|
* The function doesn't change the "object" and "source".
|
|
10
10
|
*/
|
|
11
11
|
function mergeWithoutArrays(object, source) {
|
|
12
|
-
return lodash_mergewith_1.default(object, source, function (objValue, srcValue) {
|
|
12
|
+
return (0, lodash_mergewith_1.default)(object, source, function (objValue, srcValue) {
|
|
13
13
|
if (Array.isArray(objValue)) {
|
|
14
14
|
return srcValue;
|
|
15
15
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
*/
|
|
6
6
|
function randID(prefix) {
|
|
7
7
|
if (prefix === void 0) { prefix = 'id'; }
|
|
8
|
-
var id = +new Date()
|
|
9
|
-
return prefix
|
|
8
|
+
var id = "".concat(+new Date(), "_").concat(Math.round(Math.random() * 1000));
|
|
9
|
+
return "".concat(prefix, "_").concat(id);
|
|
10
10
|
}
|
|
11
11
|
exports.default = randID;
|
|
@@ -2,47 +2,85 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var vevet_dom_1 = require("vevet-dom");
|
|
4
4
|
var SmoothScroll_1 = require("../../components/scroll/smooth-scroll/SmoothScroll");
|
|
5
|
+
var common_1 = require("../common");
|
|
6
|
+
var instances = [];
|
|
5
7
|
/**
|
|
6
8
|
* Add OnScroll event
|
|
7
9
|
*/
|
|
8
|
-
function onScroll(
|
|
9
|
-
var
|
|
10
|
-
if
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
function onScroll(_a) {
|
|
11
|
+
var container = _a.container, callback = _a.callback, _b = _a.isPassive, isPassive = _b === void 0 ? false : _b;
|
|
12
|
+
// check if listeners for this element already exist
|
|
13
|
+
var instance = instances.find(function (data) { return (data.container === container && data.isPassive === isPassive); });
|
|
14
|
+
var callbackId = (0, common_1.randID)('scroll-event');
|
|
15
|
+
// if a listener exists, we just add a new callback to its stack
|
|
16
|
+
if (instance) {
|
|
17
|
+
instance.callbacks.push({
|
|
18
|
+
id: callbackId,
|
|
19
|
+
callback: callback,
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
// otherwise we create a new instance
|
|
24
|
+
instance = {
|
|
25
|
+
id: (0, common_1.randID)('scroll-event-instance'),
|
|
26
|
+
container: container,
|
|
27
|
+
callbacks: [{
|
|
28
|
+
id: callbackId,
|
|
29
|
+
callback: callback,
|
|
30
|
+
}],
|
|
31
|
+
isPassive: isPassive,
|
|
32
|
+
listeners: [],
|
|
33
|
+
};
|
|
34
|
+
instances.push(instance);
|
|
35
|
+
// vars
|
|
36
|
+
var listeners = instance.listeners;
|
|
37
|
+
// smooth scroll events
|
|
38
|
+
if (container instanceof SmoothScroll_1.SmoothScroll) {
|
|
39
|
+
listeners.push(container.addCallback('scroll', function () {
|
|
40
|
+
var scrollTop = container.scrollTop, scrollLeft = container.scrollLeft;
|
|
41
|
+
for (var index = 0; index < instance.callbacks.length; index += 1) {
|
|
42
|
+
instance.callbacks[index].callback({
|
|
43
|
+
scrollTop: scrollTop,
|
|
44
|
+
scrollLeft: scrollLeft,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
22
48
|
}
|
|
23
49
|
else {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
listeners.push(vevet_dom_1.addEventListener(
|
|
28
|
-
var scrollTop =
|
|
29
|
-
?
|
|
30
|
-
var scrollLeft =
|
|
31
|
-
?
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
50
|
+
// dom scroll events
|
|
51
|
+
var isWindow_1 = container instanceof Window;
|
|
52
|
+
var domContainer_1 = (0, vevet_dom_1.selectOne)(container);
|
|
53
|
+
listeners.push((0, vevet_dom_1.addEventListener)(domContainer_1, 'scroll', function () {
|
|
54
|
+
var scrollTop = isWindow_1
|
|
55
|
+
? domContainer_1.pageYOffset : domContainer_1.scrollTop;
|
|
56
|
+
var scrollLeft = isWindow_1
|
|
57
|
+
? domContainer_1.pageXOffset : domContainer_1.scrollLeft;
|
|
58
|
+
for (var index = 0; index < instance.callbacks.length; index += 1) {
|
|
59
|
+
instance.callbacks[index].callback({
|
|
60
|
+
scrollTop: scrollTop,
|
|
61
|
+
scrollLeft: scrollLeft,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
passive: isPassive,
|
|
66
|
+
}));
|
|
39
67
|
}
|
|
40
68
|
}
|
|
41
69
|
return {
|
|
42
70
|
remove: function () {
|
|
43
|
-
|
|
44
|
-
|
|
71
|
+
var newCallbacks = instance.callbacks.filter(function (item) {
|
|
72
|
+
if (item.id !== callbackId) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
45
76
|
});
|
|
77
|
+
instance.callbacks = newCallbacks;
|
|
78
|
+
if (newCallbacks.length === 0) {
|
|
79
|
+
instance.listeners.forEach(function (listener) {
|
|
80
|
+
listener.remove();
|
|
81
|
+
});
|
|
82
|
+
instances = instances.filter(function (item) { return item.id !== instance.id; });
|
|
83
|
+
}
|
|
46
84
|
},
|
|
47
85
|
};
|
|
48
86
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Clamp the value between two points
|
|
5
5
|
*/
|
|
6
|
-
function
|
|
6
|
+
function clamp(val, scope) {
|
|
7
7
|
if (scope === void 0) { scope = [0, 1]; }
|
|
8
8
|
if (val < scope[0]) {
|
|
9
9
|
return scope[0];
|
|
@@ -13,4 +13,4 @@ function boundVal(val, scope) {
|
|
|
13
13
|
}
|
|
14
14
|
return val;
|
|
15
15
|
}
|
|
16
|
-
exports.default =
|
|
16
|
+
exports.default = clamp;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var scoped_1 = __importDefault(require("./scoped"));
|
|
7
|
+
var clamp_1 = __importDefault(require("./clamp"));
|
|
8
|
+
/**
|
|
9
|
+
* Get progress relatively to the scope and clamp it within two points
|
|
10
|
+
*/
|
|
11
|
+
function clampScoped(val, scope, clampScope) {
|
|
12
|
+
if (scope === void 0) { scope = [0, 1]; }
|
|
13
|
+
if (clampScope === void 0) { clampScope = [0, 1]; }
|
|
14
|
+
return (0, clamp_1.default)((0, scoped_1.default)(val, scope), clampScope);
|
|
15
|
+
}
|
|
16
|
+
exports.default = clampScoped;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Check if the value is within the scope
|
|
5
|
+
*/
|
|
6
|
+
function inScope(val, scopeValue) {
|
|
7
|
+
if (scopeValue === void 0) { scopeValue = [0, 1]; }
|
|
8
|
+
return val >= scopeValue[0] && val <= scopeValue[1];
|
|
9
|
+
}
|
|
10
|
+
exports.default = inScope;
|
|
@@ -3,12 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var
|
|
8
|
-
exports.
|
|
6
|
+
exports.wrap = exports.clampScope = exports.inScope = exports.spreadScope = exports.scoped = exports.lerp = exports.clamp = void 0;
|
|
7
|
+
var clamp_1 = __importDefault(require("./clamp"));
|
|
8
|
+
exports.clamp = clamp_1.default;
|
|
9
9
|
var lerp_1 = __importDefault(require("./lerp"));
|
|
10
10
|
exports.lerp = lerp_1.default;
|
|
11
|
-
var
|
|
12
|
-
exports.
|
|
13
|
-
var
|
|
14
|
-
exports.
|
|
11
|
+
var scoped_1 = __importDefault(require("./scoped"));
|
|
12
|
+
exports.scoped = scoped_1.default;
|
|
13
|
+
var spreadScope_1 = __importDefault(require("./spreadScope"));
|
|
14
|
+
exports.spreadScope = spreadScope_1.default;
|
|
15
|
+
var inScope_1 = __importDefault(require("./inScope"));
|
|
16
|
+
exports.inScope = inScope_1.default;
|
|
17
|
+
var clampScope_1 = __importDefault(require("./clampScope"));
|
|
18
|
+
exports.clampScope = clampScope_1.default;
|
|
19
|
+
var wrap_1 = __importDefault(require("./wrap"));
|
|
20
|
+
exports.wrap = wrap_1.default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Get progress relatively to the scope.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* scope(.35, [0, 1]);
|
|
9
|
+
* // => .5
|
|
10
|
+
* scope(.35, [.25, 1]);
|
|
11
|
+
* // => .133
|
|
12
|
+
*/
|
|
13
|
+
function scoped(val, scopeValue) {
|
|
14
|
+
if (scopeValue === void 0) { scopeValue = [0, 1]; }
|
|
15
|
+
var result = (val - scopeValue[0]) / (scopeValue[1] - scopeValue[0]);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.default = scoped;
|