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.
Files changed (130) hide show
  1. package/build/cdn/index.js +1 -1
  2. package/build/cjs/app/Application.js +8 -8
  3. package/build/cjs/app/events/PageLoad.js +3 -3
  4. package/build/cjs/app/events/Viewport.js +5 -5
  5. package/build/cjs/base/Callbacks.js +3 -3
  6. package/build/cjs/base/Module.js +16 -7
  7. package/build/cjs/base/MutableProp.js +10 -10
  8. package/build/cjs/components/animation-frame/AnimationFrame.js +1 -1
  9. package/build/cjs/components/canvas/Ctx2D.js +7 -3
  10. package/build/cjs/components/canvas/Ctx2DPrerender.js +17 -3
  11. package/build/cjs/components/cursor/CustomCursor.js +12 -12
  12. package/build/cjs/components/dragger/Dragger.js +8 -8
  13. package/build/cjs/components/dragger/DraggerMove.js +2 -2
  14. package/build/cjs/components/loading/Preloader.js +5 -5
  15. package/build/cjs/components/loading/ProgressPreloader.js +17 -5
  16. package/build/cjs/components/page/Page.js +37 -9
  17. package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +2 -2
  18. package/build/cjs/components/scroll/scrollable/ScrollEventsBase.js +1 -1
  19. package/build/cjs/components/scroll/scrollable/ScrollView.js +133 -73
  20. package/build/cjs/components/scroll/scrollbar/Bar.js +18 -15
  21. package/build/cjs/components/scroll/scrollbar/ScrollBar.js +9 -7
  22. package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +26 -22
  23. package/build/cjs/components/text/SplitText.js +34 -12
  24. package/build/cjs/components/timeline/StaticTimeline.js +4 -4
  25. package/build/cjs/components/timeline/Timeline.js +2 -2
  26. package/build/cjs/handlers/wheel/WheelHandler.js +4 -4
  27. package/build/cjs/utils/common/mergeWithoutArrays.js +1 -1
  28. package/build/cjs/utils/common/randID.js +2 -2
  29. package/build/cjs/utils/listeners/onScroll.js +66 -28
  30. package/build/cjs/utils/math/{boundVal.js → clamp.js} +3 -3
  31. package/build/cjs/utils/math/clampScope.js +16 -0
  32. package/build/cjs/utils/math/inScope.js +10 -0
  33. package/build/cjs/utils/math/index.js +13 -7
  34. package/build/cjs/utils/math/scoped.js +18 -0
  35. package/build/cjs/utils/math/{spreadScopeProgress.js → spreadScope.js} +2 -2
  36. package/build/cjs/utils/math/wrap.js +13 -0
  37. package/build/es/base/Module.js +2 -4
  38. package/build/es/components/animation-frame/AnimationFrame.js +2 -2
  39. package/build/es/components/canvas/Ctx2D.js +6 -2
  40. package/build/es/components/canvas/Ctx2DPrerender.js +16 -2
  41. package/build/es/components/loading/ProgressPreloader.js +14 -2
  42. package/build/es/components/page/Page.js +32 -8
  43. package/build/es/components/scroll/scrollable/ScrollView.js +112 -62
  44. package/build/es/components/scroll/scrollbar/Bar.js +9 -6
  45. package/build/es/components/scroll/scrollbar/ScrollBar.js +3 -1
  46. package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +13 -9
  47. package/build/es/components/text/SplitText.js +25 -3
  48. package/build/es/components/timeline/StaticTimeline.js +3 -3
  49. package/build/es/components/timeline/Timeline.js +2 -2
  50. package/build/es/utils/listeners/onScroll.js +65 -28
  51. package/build/es/utils/math/{boundVal.js → clamp.js} +2 -2
  52. package/build/es/utils/math/clampScope.js +8 -0
  53. package/build/es/utils/math/inScope.js +6 -0
  54. package/build/es/utils/math/index.js +7 -4
  55. package/build/es/utils/math/scoped.js +14 -0
  56. package/build/es/utils/math/{spreadScopeProgress.js → spreadScope.js} +1 -1
  57. package/build/es/utils/math/wrap.js +10 -0
  58. package/build/types/base/Module.d.ts.map +1 -1
  59. package/build/types/components/canvas/Ctx2D.d.ts +9 -0
  60. package/build/types/components/canvas/Ctx2D.d.ts.map +1 -1
  61. package/build/types/components/canvas/Ctx2DPrerender.d.ts +1 -1
  62. package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -1
  63. package/build/types/components/loading/ProgressPreloader.d.ts +7 -0
  64. package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -1
  65. package/build/types/components/page/Page.d.ts +2 -0
  66. package/build/types/components/page/Page.d.ts.map +1 -1
  67. package/build/types/components/scroll/scrollable/ScrollView.d.ts +40 -14
  68. package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
  69. package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -1
  70. package/build/types/components/scroll/scrollbar/ScrollBar.d.ts +4 -0
  71. package/build/types/components/scroll/scrollbar/ScrollBar.d.ts.map +1 -1
  72. package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts +4 -0
  73. package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -1
  74. package/build/types/components/text/SplitText.d.ts +10 -0
  75. package/build/types/components/text/SplitText.d.ts.map +1 -1
  76. package/build/types/utils/listeners/onScroll.d.ts +10 -6
  77. package/build/types/utils/listeners/onScroll.d.ts.map +1 -1
  78. package/build/types/utils/math/clamp.d.ts +5 -0
  79. package/build/types/utils/math/clamp.d.ts.map +1 -0
  80. package/build/types/utils/math/clampScope.d.ts +5 -0
  81. package/build/types/utils/math/clampScope.d.ts.map +1 -0
  82. package/build/types/utils/math/inScope.d.ts +5 -0
  83. package/build/types/utils/math/inScope.d.ts.map +1 -0
  84. package/build/types/utils/math/index.d.ts +7 -4
  85. package/build/types/utils/math/index.d.ts.map +1 -1
  86. package/build/types/utils/math/scoped.d.ts +12 -0
  87. package/build/types/utils/math/scoped.d.ts.map +1 -0
  88. package/build/types/utils/math/spreadScope.d.ts +5 -0
  89. package/build/types/utils/math/spreadScope.d.ts.map +1 -0
  90. package/build/types/utils/math/wrap.d.ts +5 -0
  91. package/build/types/utils/math/wrap.d.ts.map +1 -0
  92. package/package.json +3 -3
  93. package/src/ts/base/Module.ts +5 -4
  94. package/src/ts/components/animation-frame/AnimationFrame.ts +2 -2
  95. package/src/ts/components/canvas/Ctx2D.ts +16 -1
  96. package/src/ts/components/canvas/Ctx2DPrerender.ts +19 -6
  97. package/src/ts/components/loading/ProgressPreloader.ts +21 -2
  98. package/src/ts/components/page/Page.ts +34 -8
  99. package/src/ts/components/scroll/scrollable/ScrollView.ts +155 -86
  100. package/src/ts/components/scroll/scrollbar/Bar.ts +9 -6
  101. package/src/ts/components/scroll/scrollbar/ScrollBar.ts +7 -0
  102. package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +17 -8
  103. package/src/ts/components/text/SplitText.ts +38 -2
  104. package/src/ts/components/timeline/StaticTimeline.ts +4 -4
  105. package/src/ts/components/timeline/Timeline.ts +2 -2
  106. package/src/ts/utils/listeners/onScroll.ts +101 -38
  107. package/src/ts/utils/math/{boundVal.ts → clamp.ts} +3 -3
  108. package/src/ts/utils/math/clampScope.ts +16 -0
  109. package/src/ts/utils/math/inScope.ts +9 -0
  110. package/src/ts/utils/math/index.ts +12 -6
  111. package/src/ts/utils/math/scoped.ts +17 -0
  112. package/src/ts/utils/math/{spreadScopeProgress.ts → spreadScope.ts} +2 -2
  113. package/src/ts/utils/math/wrap.ts +18 -0
  114. package/build/cjs/components/scroll/custom-scroll/CustomScroll.js +0 -517
  115. package/build/cjs/components/split-text/SplitText.js +0 -233
  116. package/build/cjs/utils/math/scopeProgress.js +0 -25
  117. package/build/es/components/scroll/custom-scroll/CustomScroll.js +0 -486
  118. package/build/es/components/split-text/SplitText.js +0 -199
  119. package/build/es/utils/math/scopeProgress.js +0 -22
  120. package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts +0 -322
  121. package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts.map +0 -1
  122. package/build/types/components/split-text/SplitText.d.ts +0 -118
  123. package/build/types/components/split-text/SplitText.d.ts.map +0 -1
  124. package/build/types/utils/math/boundVal.d.ts +0 -5
  125. package/build/types/utils/math/boundVal.d.ts.map +0 -1
  126. package/build/types/utils/math/scopeProgress.d.ts +0 -20
  127. package/build/types/utils/math/scopeProgress.d.ts.map +0 -1
  128. package/build/types/utils/math/spreadScopeProgress.d.ts +0 -5
  129. package/build/types/utils/math/spreadScopeProgress.d.ts.map +0 -1
  130. package/src/ts/utils/math/scopeProgress.ts +0 -23
@@ -1,517 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.CustomScroll = void 0;
22
- var vevet_dom_1 = require("vevet-dom");
23
- var normalize_wheel_1 = __importDefault(require("normalize-wheel"));
24
- var Component_1 = require("../../../base/Component");
25
- var common_1 = require("../../../utils/common");
26
- var AnimationFrame_1 = require("../../animation-frame/AnimationFrame");
27
- var boundVal_1 = __importDefault(require("../../../utils/math/boundVal"));
28
- var math_1 = require("../../../utils/math");
29
- /**
30
- * Create smooth scrolling.
31
- */
32
- var CustomScroll = /** @class */ (function (_super) {
33
- __extends(CustomScroll, _super);
34
- function CustomScroll(initialProp, init) {
35
- if (initialProp === void 0) { initialProp = {}; }
36
- if (init === void 0) { init = true; }
37
- var _this = _super.call(this, initialProp, false) || this;
38
- var selectors = _this.prop.selectors;
39
- // set default variables
40
- _this._targetLeft = 0;
41
- _this._targetTop = 0;
42
- _this._scrollLeft = 0;
43
- _this._scrollTop = 0;
44
- _this._scrollWidth = 0;
45
- _this._scrollHeight = 0;
46
- _this._clientWidth = 0;
47
- _this._clientHeight = 0;
48
- _this._instant = false;
49
- // get outer elements
50
- _this._outer = vevet_dom_1.selectOne(selectors.outer);
51
- if (!(_this._outer instanceof HTMLElement)) {
52
- throw new Error(selectors.outer + " is not a HTMLElement");
53
- }
54
- _this._outer.classList.add(_this.prefix);
55
- // get or create container
56
- var existingContainer = vevet_dom_1.selectOne("." + _this.prefix + "__container", _this.outer);
57
- if (vevet_dom_1.isElement(existingContainer)) {
58
- _this._container = existingContainer;
59
- _this._containerExists = true;
60
- }
61
- else {
62
- _this._container = vevet_dom_1.createElement('div', {
63
- class: _this.prefix + "__container",
64
- parent: _this.outer,
65
- children: Array.from(_this.outer.children),
66
- });
67
- _this._containerExists = false;
68
- }
69
- // get scrollable elements
70
- if (selectors.elements) {
71
- _this._elements = Array.from(vevet_dom_1.selectAll(selectors.elements, _this._outer));
72
- }
73
- else {
74
- _this._elements = [_this._container];
75
- }
76
- _this._elementsLength = _this._elements.length;
77
- // initialize the class
78
- if (init) {
79
- _this.init();
80
- }
81
- return _this;
82
- }
83
- Object.defineProperty(CustomScroll.prototype, "prefix", {
84
- get: function () {
85
- return this._app.prefix + "custom-scroll";
86
- },
87
- enumerable: false,
88
- configurable: true
89
- });
90
- Object.defineProperty(CustomScroll.prototype, "outer", {
91
- get: function () {
92
- return this._outer;
93
- },
94
- enumerable: false,
95
- configurable: true
96
- });
97
- Object.defineProperty(CustomScroll.prototype, "container", {
98
- get: function () {
99
- return this._container;
100
- },
101
- enumerable: false,
102
- configurable: true
103
- });
104
- Object.defineProperty(CustomScroll.prototype, "elements", {
105
- get: function () {
106
- return this._elements;
107
- },
108
- enumerable: false,
109
- configurable: true
110
- });
111
- Object.defineProperty(CustomScroll.prototype, "targetLeft", {
112
- get: function () {
113
- return this._targetLeft;
114
- },
115
- set: function (val) {
116
- this.targetLeftDry = val;
117
- this.enable();
118
- },
119
- enumerable: false,
120
- configurable: true
121
- });
122
- Object.defineProperty(CustomScroll.prototype, "targetLeftDry", {
123
- get: function () {
124
- return this._targetLeft;
125
- },
126
- /**
127
- * Set value without animation request
128
- */
129
- set: function (val) {
130
- this._targetLeft = boundVal_1.default(val, [0, this.maxScrollableWidth]);
131
- },
132
- enumerable: false,
133
- configurable: true
134
- });
135
- Object.defineProperty(CustomScroll.prototype, "targetTop", {
136
- get: function () {
137
- return this._targetTop;
138
- },
139
- set: function (val) {
140
- this.targetTopDry = val;
141
- this.enable();
142
- },
143
- enumerable: false,
144
- configurable: true
145
- });
146
- Object.defineProperty(CustomScroll.prototype, "targetTopDry", {
147
- get: function () {
148
- return this._targetTop;
149
- },
150
- /**
151
- * Set value without animation request
152
- */
153
- set: function (val) {
154
- this._targetTop = boundVal_1.default(val, [0, this.maxScrollableHeight]);
155
- },
156
- enumerable: false,
157
- configurable: true
158
- });
159
- Object.defineProperty(CustomScroll.prototype, "scrollLeft", {
160
- get: function () {
161
- return this._scrollLeft;
162
- },
163
- set: function (val) {
164
- this.targetLeftDry = val;
165
- this._scrollLeft = this._targetLeft;
166
- this.enable();
167
- },
168
- enumerable: false,
169
- configurable: true
170
- });
171
- Object.defineProperty(CustomScroll.prototype, "scrollTop", {
172
- get: function () {
173
- return this._scrollTop;
174
- },
175
- set: function (val) {
176
- this.targetTopDry = val;
177
- this._scrollTop = this._targetTop;
178
- this.enable();
179
- },
180
- enumerable: false,
181
- configurable: true
182
- });
183
- Object.defineProperty(CustomScroll.prototype, "scrollWidth", {
184
- get: function () {
185
- return this._scrollWidth;
186
- },
187
- enumerable: false,
188
- configurable: true
189
- });
190
- Object.defineProperty(CustomScroll.prototype, "scrollHeight", {
191
- get: function () {
192
- return this._scrollHeight;
193
- },
194
- enumerable: false,
195
- configurable: true
196
- });
197
- Object.defineProperty(CustomScroll.prototype, "clientWidth", {
198
- get: function () {
199
- return this._clientWidth;
200
- },
201
- enumerable: false,
202
- configurable: true
203
- });
204
- Object.defineProperty(CustomScroll.prototype, "clientHeight", {
205
- get: function () {
206
- return this._clientHeight;
207
- },
208
- enumerable: false,
209
- configurable: true
210
- });
211
- Object.defineProperty(CustomScroll.prototype, "maxScrollableWidth", {
212
- /**
213
- * Maximum scrollable area of the X axis
214
- */
215
- get: function () {
216
- return this.scrollWidth - this.clientWidth;
217
- },
218
- enumerable: false,
219
- configurable: true
220
- });
221
- Object.defineProperty(CustomScroll.prototype, "maxScrollableHeight", {
222
- /**
223
- * Maximum scrollable area of the Y axis
224
- */
225
- get: function () {
226
- return this.scrollHeight - this.clientHeight;
227
- },
228
- enumerable: false,
229
- configurable: true
230
- });
231
- CustomScroll.prototype._getDefaultProp = function () {
232
- var prop = {
233
- selectors: {
234
- outer: '#v-custom-scroll',
235
- elements: false,
236
- },
237
- enabled: true,
238
- animationFrame: false,
239
- recalculateSizes: true,
240
- useWheel: true,
241
- autoStop: true,
242
- isHorizontal: false,
243
- lerp: 0.1,
244
- lerpToFixed: false,
245
- };
246
- return common_1.mergeWithoutArrays(_super.prototype._getDefaultProp.call(this), prop);
247
- };
248
- // Set Events
249
- CustomScroll.prototype._setEvents = function () {
250
- var _this = this;
251
- // update sizes
252
- this.resize();
253
- this.addViewportCallback('', function () {
254
- _this.resize(true);
255
- });
256
- // wheel
257
- this.addEventListeners(this.outer, 'wheel', function (e) {
258
- _this._handleWheel(e);
259
- }, {
260
- passive: true,
261
- });
262
- // on scroll
263
- this.addEventListeners(this.outer, 'scroll', function () {
264
- _this.outer.scrollTop = 0;
265
- _this.outer.scrollLeft = 0;
266
- });
267
- };
268
- CustomScroll.prototype._onPropMutate = function () {
269
- _super.prototype._onPropMutate.call(this);
270
- this.resize();
271
- this._toggle();
272
- };
273
- /**
274
- * Recalculate scroll sizes
275
- */
276
- CustomScroll.prototype.resize = function (
277
- /**
278
- * If the method was called natively on window resize
279
- */
280
- native) {
281
- if (native === void 0) { native = false; }
282
- // get elements
283
- var _a = this, container = _a.container, outer = _a.outer;
284
- // get sizes
285
- this._clientWidth = outer.clientWidth;
286
- this._clientHeight = outer.clientHeight;
287
- this._scrollWidth = boundVal_1.default(container.clientWidth, [this.clientWidth, Infinity]);
288
- this._scrollHeight = boundVal_1.default(container.clientHeight, [this.clientHeight, Infinity]);
289
- // force instant change
290
- // it means that after resizing, scrolling will be instantaneous for a while
291
- if (native) {
292
- this._instant = true;
293
- }
294
- // sometimes after resizing it may happen that targets are less or more
295
- // than maximum values of scrolling
296
- // that's why fix it here
297
- if (native) {
298
- this.targetLeft = parseInt(this.targetLeft.toFixed(0), 10);
299
- this.targetTop = parseInt(this.targetTop.toFixed(0), 10);
300
- }
301
- // render elements
302
- this._updateElementsProp();
303
- this.render();
304
- // launch callbacks
305
- this.callbacks.tbt('resize', false);
306
- };
307
- /**
308
- * Recalculate scroll sizes
309
- */
310
- CustomScroll.prototype._recalculateSizes = function () {
311
- var container = this.container;
312
- var height = container.clientHeight;
313
- var width = container.clientWidth;
314
- if ((height !== this.scrollHeight) || (width !== this.scrollHeight)) {
315
- this.resize();
316
- }
317
- };
318
- /**
319
- * Update elements' properties
320
- */
321
- CustomScroll.prototype._updateElementsProp = function () {
322
- for (var index = 0; index < this._elementsLength; index += 1) {
323
- var el = this._elements[index];
324
- // update scroll values
325
- el.customScrollLeft = this.scrollLeft;
326
- el.customScrollTop = this.scrollTop;
327
- // update easing
328
- var easingAttr = el.getAttribute(this.prefix + "-ease");
329
- if (easingAttr) {
330
- try {
331
- el.customScrollLerpEase = parseFloat(easingAttr);
332
- }
333
- catch (e) {
334
- //
335
- }
336
- }
337
- }
338
- };
339
- /**
340
- * Event on wheel
341
- */
342
- CustomScroll.prototype._handleWheel = function (evt) {
343
- var prop = this.prop;
344
- if (!prop.enabled || prop.useWheel) {
345
- return;
346
- }
347
- // stop propagation if needed
348
- if ((this.targetLeft < 0
349
- || this.targetLeft === this.scrollWidth - this.clientWidth)
350
- || (this.targetTop < 0
351
- || this.targetTop === this.scrollHeight - this.clientHeight)) {
352
- evt.stopPropagation();
353
- }
354
- // get normalized delta
355
- var delta = normalize_wheel_1.default(evt);
356
- // set new scroll targets
357
- this.targetLeftDry += prop.isHorizontal ? delta.pixelY : delta.pixelX;
358
- this.targetTopDry += prop.isHorizontal ? delta.pixelX : delta.pixelY;
359
- // play scroll
360
- this.enable();
361
- // launch events
362
- this.callbacks.tbt('wheel', evt);
363
- };
364
- /**
365
- * Toggle animation: Enable / Disable scrolling
366
- */
367
- CustomScroll.prototype._toggle = function () {
368
- if (this.prop.enabled) {
369
- this.enable();
370
- }
371
- else {
372
- this.disable();
373
- }
374
- };
375
- /**
376
- * Enable scrolling
377
- */
378
- CustomScroll.prototype.enable = function () {
379
- // set animation callback for the outer AnimationFrame
380
- if (!!this.prop.animationFrame && !this._outerAnimationFrameEvent) {
381
- this._outerAnimationFrameEvent = this.prop.animationFrame.addCallback('frame', this.render.bind(this));
382
- }
383
- else {
384
- // otherwise, check if inner AnimationFrame is created
385
- if (!this._animationFrame) {
386
- this._animationFrame = new AnimationFrame_1.AnimationFrame();
387
- this._animationFrame.addCallback('frame', this.render.bind(this));
388
- }
389
- this._animationFrame.play();
390
- }
391
- };
392
- /**
393
- * Disable scrolling
394
- */
395
- CustomScroll.prototype.disable = function () {
396
- if (!!this._outerAnimationFrameEvent && !!this.prop.animationFrame) {
397
- this._outerAnimationFrameEvent.remove();
398
- }
399
- if (this._animationFrame) {
400
- this._animationFrame.pause();
401
- }
402
- };
403
- /**
404
- * Render elements
405
- */
406
- CustomScroll.prototype.render = function () {
407
- // vars
408
- var prop = this.prop;
409
- // recalculate sizes
410
- if (!prop.recalculateSizes) {
411
- this._recalculateSizes();
412
- }
413
- // calculate scroll values
414
- this._scrollLeft = this._lerp(this._scrollLeft, this._targetLeft);
415
- this._scrollTop = this._lerp(this._scrollTop, this._targetTop);
416
- // change elements' values
417
- this._calcElements();
418
- // render
419
- this._renderElements();
420
- // disable instant scrolling
421
- if (this._instant) {
422
- this._instant = false;
423
- }
424
- // launch events
425
- this.callbacks.tbt('render', false);
426
- // stop animation frame if values are approximated
427
- var yDiff = Math.abs(this._targetTop - this._scrollTop);
428
- var xDiff = Math.abs(this._targetLeft - this._scrollLeft);
429
- if (xDiff === 0 && yDiff === 0 && prop.autoStop) {
430
- this.disable();
431
- this.callbacks.tbt('approximate', false);
432
- }
433
- };
434
- /**
435
- * Calculate elements' values.
436
- * @param {boolean} instant - If animation is to be implemented instantly.
437
- */
438
- CustomScroll.prototype._calcElements = function () {
439
- for (var index = 0; index < this._elementsLength; index += 1) {
440
- var el = this._elements[index];
441
- // get element ease
442
- var ease = this._getLerpEase(el);
443
- // change values
444
- if (ease === this.prop.lerp) {
445
- el.customScrollLeft = this._scrollLeft;
446
- el.customScrollTop = this._scrollTop;
447
- }
448
- else {
449
- el.customScrollLeft = this._lerp(el.customScrollLeft, this._targetLeft, ease);
450
- el.customScrollTop = this._lerp(el.customScrollTop, this._targetTop, ease);
451
- }
452
- }
453
- };
454
- /**
455
- * Interpolate values
456
- */
457
- CustomScroll.prototype._lerp = function (current, target, ease) {
458
- if (ease === void 0) { ease = this.prop.lerp; }
459
- var currentEase = this._instant ? 1 : ease;
460
- var val = math_1.lerp(current, target, currentEase);
461
- // round the values
462
- if (typeof this.prop.lerpToFixed === 'number') {
463
- var fixed = Math.round(this.prop.lerpToFixed);
464
- return parseFloat(val.toFixed(fixed));
465
- }
466
- return val;
467
- };
468
- /**
469
- * Get element ease
470
- */
471
- CustomScroll.prototype._getLerpEase = function (el) {
472
- if (el) {
473
- return el.customScrollLerpEase || this.prop.lerp;
474
- }
475
- return this.prop.lerp;
476
- };
477
- /**
478
- * Render elements
479
- */
480
- CustomScroll.prototype._renderElements = function () {
481
- for (var index = 0; index < this._elementsLength; index += 1) {
482
- var el = this._elements[index];
483
- // coords
484
- var x = -el.customScrollLeft;
485
- var y = -el.customScrollTop;
486
- // set styles
487
- el.style.transform = "matrix3d(1,0,0.00,0,0.00,1,0.00,0,0,0,1,0, " + x + ", " + y + ", 0,1)";
488
- }
489
- };
490
- /**
491
- * Destroy the scroll
492
- */
493
- CustomScroll.prototype._destroy = function () {
494
- _super.prototype._destroy.call(this);
495
- // disable animation
496
- this.disable();
497
- if (this._animationFrame) {
498
- this._animationFrame.destroy();
499
- }
500
- // destroy container
501
- if (!this._containerExists) {
502
- while (this._container.firstChild) {
503
- this._outer.appendChild(this._container.firstChild);
504
- }
505
- this._container.remove();
506
- }
507
- // remove classes
508
- this._outer.classList.remove(this.prefix);
509
- // reset styles
510
- for (var index = 0; index < this._elementsLength; index += 1) {
511
- var el = this._elements[index];
512
- el.style.transform = '';
513
- }
514
- };
515
- return CustomScroll;
516
- }(Component_1.Component));
517
- exports.CustomScroll = CustomScroll;