vevet 3.0.0-beta.1 → 3.0.0-beta.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 (126) hide show
  1. package/lib/cjs/Application/events/Viewport/index.js +1 -1
  2. package/lib/cjs/Application/events/Viewport/index.js.map +1 -1
  3. package/lib/cjs/version.js +1 -1
  4. package/lib/esm/Application/events/PageLoad/index.js +54 -28
  5. package/lib/esm/Application/events/PageLoad/index.js.map +1 -1
  6. package/lib/esm/Application/events/Viewport/index.js +180 -107
  7. package/lib/esm/Application/events/Viewport/index.js.map +1 -1
  8. package/lib/esm/Application/index.js +178 -96
  9. package/lib/esm/Application/index.js.map +1 -1
  10. package/lib/esm/base/Callbacks/index.js +78 -45
  11. package/lib/esm/base/Callbacks/index.js.map +1 -1
  12. package/lib/esm/base/Component/index.js +31 -10
  13. package/lib/esm/base/Component/index.js.map +1 -1
  14. package/lib/esm/base/Module/index.js +132 -77
  15. package/lib/esm/base/Module/index.js.map +1 -1
  16. package/lib/esm/base/MutableProps/index.js +49 -30
  17. package/lib/esm/base/MutableProps/index.js.map +1 -1
  18. package/lib/esm/base/Plugin/index.js +35 -13
  19. package/lib/esm/base/Plugin/index.js.map +1 -1
  20. package/lib/esm/components/AnimationFrame/index.js +98 -55
  21. package/lib/esm/components/AnimationFrame/index.js.map +1 -1
  22. package/lib/esm/components/BaseTimeline/index.js +88 -41
  23. package/lib/esm/components/BaseTimeline/index.js.map +1 -1
  24. package/lib/esm/components/Ctx2D/index.js +150 -82
  25. package/lib/esm/components/Ctx2D/index.js.map +1 -1
  26. package/lib/esm/components/Ctx2DPrerender/index.js +54 -20
  27. package/lib/esm/components/Ctx2DPrerender/index.js.map +1 -1
  28. package/lib/esm/components/CustomCursor/index.js +216 -149
  29. package/lib/esm/components/CustomCursor/index.js.map +1 -1
  30. package/lib/esm/components/DraggerBase/index.js +164 -98
  31. package/lib/esm/components/DraggerBase/index.js.map +1 -1
  32. package/lib/esm/components/DraggerDirection/index.js +42 -10
  33. package/lib/esm/components/DraggerDirection/index.js.map +1 -1
  34. package/lib/esm/components/DraggerMove/index.js +83 -42
  35. package/lib/esm/components/DraggerMove/index.js.map +1 -1
  36. package/lib/esm/components/Preloader/index.js +135 -77
  37. package/lib/esm/components/Preloader/index.js.map +1 -1
  38. package/lib/esm/components/ProgressPreloader/index.js +190 -112
  39. package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
  40. package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js +10 -9
  41. package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js.map +1 -1
  42. package/lib/esm/components/ProgressPreloader/utils/preloadImage.js +3 -3
  43. package/lib/esm/components/ProgressPreloader/utils/preloadImage.js.map +1 -1
  44. package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js +2 -2
  45. package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js.map +1 -1
  46. package/lib/esm/components/ScrollBar/Bar/index.js +136 -90
  47. package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
  48. package/lib/esm/components/ScrollBar/index.js +118 -70
  49. package/lib/esm/components/ScrollBar/index.js.map +1 -1
  50. package/lib/esm/components/ScrollView/index.js +154 -103
  51. package/lib/esm/components/ScrollView/index.js.map +1 -1
  52. package/lib/esm/components/SectionScrollProgress/index.js +170 -95
  53. package/lib/esm/components/SectionScrollProgress/index.js.map +1 -1
  54. package/lib/esm/components/SmoothScroll/AnimatonFrame.js +37 -20
  55. package/lib/esm/components/SmoothScroll/AnimatonFrame.js.map +1 -1
  56. package/lib/esm/components/SmoothScroll/Elements.js +59 -42
  57. package/lib/esm/components/SmoothScroll/Elements.js.map +1 -1
  58. package/lib/esm/components/SmoothScroll/index.js +304 -205
  59. package/lib/esm/components/SmoothScroll/index.js.map +1 -1
  60. package/lib/esm/components/SmoothScrollDragPlugin/index.js +86 -48
  61. package/lib/esm/components/SmoothScrollDragPlugin/index.js.map +1 -1
  62. package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js +70 -34
  63. package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js.map +1 -1
  64. package/lib/esm/components/SplitText/index.js +177 -117
  65. package/lib/esm/components/SplitText/index.js.map +1 -1
  66. package/lib/esm/components/Timeline/index.js +88 -45
  67. package/lib/esm/components/Timeline/index.js.map +1 -1
  68. package/lib/esm/utils/common/mergeWithoutArrays.js +1 -1
  69. package/lib/esm/utils/common/mergeWithoutArrays.js.map +1 -1
  70. package/lib/esm/utils/common/normalizedTimeoutCallback.js +3 -3
  71. package/lib/esm/utils/common/normalizedTimeoutCallback.js.map +1 -1
  72. package/lib/esm/utils/common/pickObjectProps.js +2 -2
  73. package/lib/esm/utils/common/pickObjectProps.js.map +1 -1
  74. package/lib/esm/utils/common/times.js +2 -2
  75. package/lib/esm/utils/common/times.js.map +1 -1
  76. package/lib/esm/utils/common/uid.js +4 -3
  77. package/lib/esm/utils/common/uid.js.map +1 -1
  78. package/lib/esm/utils/image/load.js +26 -15
  79. package/lib/esm/utils/image/load.js.map +1 -1
  80. package/lib/esm/utils/image/pathsToProps.js +5 -5
  81. package/lib/esm/utils/image/pathsToProps.js.map +1 -1
  82. package/lib/esm/utils/image/sizesToSrcSet.js +5 -5
  83. package/lib/esm/utils/image/sizesToSrcSet.js.map +1 -1
  84. package/lib/esm/utils/internal/fetchWebpSupport.js +3 -3
  85. package/lib/esm/utils/internal/fetchWebpSupport.js.map +1 -1
  86. package/lib/esm/utils/internal/getDeviceInfo.js +7 -7
  87. package/lib/esm/utils/internal/getDeviceInfo.js.map +1 -1
  88. package/lib/esm/utils/internal/onResize.js +16 -13
  89. package/lib/esm/utils/internal/onResize.js.map +1 -1
  90. package/lib/esm/utils/math/clamp.js +2 -1
  91. package/lib/esm/utils/math/clamp.js.map +1 -1
  92. package/lib/esm/utils/math/clampScope.js +3 -1
  93. package/lib/esm/utils/math/clampScope.js.map +1 -1
  94. package/lib/esm/utils/math/easing.js +5 -1
  95. package/lib/esm/utils/math/easing.js.map +1 -1
  96. package/lib/esm/utils/math/inScope.js +2 -1
  97. package/lib/esm/utils/math/inScope.js.map +1 -1
  98. package/lib/esm/utils/math/lerp.js +4 -3
  99. package/lib/esm/utils/math/lerp.js.map +1 -1
  100. package/lib/esm/utils/math/normalizeNestedScope.js +1 -1
  101. package/lib/esm/utils/math/normalizeNestedScope.js.map +1 -1
  102. package/lib/esm/utils/math/scoped.js +3 -2
  103. package/lib/esm/utils/math/scoped.js.map +1 -1
  104. package/lib/esm/utils/math/spreadScope.js +5 -5
  105. package/lib/esm/utils/math/spreadScope.js.map +1 -1
  106. package/lib/esm/utils/math/wrap.js +2 -2
  107. package/lib/esm/utils/math/wrap.js.map +1 -1
  108. package/lib/esm/utils/scroll/getScrollValues.js +6 -5
  109. package/lib/esm/utils/scroll/getScrollValues.js.map +1 -1
  110. package/lib/esm/utils/scroll/onScroll.js +23 -20
  111. package/lib/esm/utils/scroll/onScroll.js.map +1 -1
  112. package/lib/esm/utils/scroll/scrollTo.js +12 -10
  113. package/lib/esm/utils/scroll/scrollTo.js.map +1 -1
  114. package/lib/esm/utils/scroll/scrollToElement.js +19 -8
  115. package/lib/esm/utils/scroll/scrollToElement.js.map +1 -1
  116. package/lib/esm/version.js +1 -1
  117. package/lib/esm/version.js.map +1 -1
  118. package/lib/esm/vevet.js +1 -1
  119. package/lib/esm/vevet.js.map +1 -1
  120. package/lib/types/Application/events/Viewport/index.d.ts +1 -1
  121. package/lib/types/Application/events/Viewport/index.d.ts.map +1 -1
  122. package/lib/types/version.d.ts +1 -1
  123. package/package.json +1 -1
  124. package/src/Application/events/Viewport/index.ts +1 -1
  125. package/src/Application/events/Viewport/stories/index.tsx +1 -1
  126. package/src/version.ts +1 -1
@@ -1,3 +1,29 @@
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
+ };
1
27
  import { selectOne } from 'vevet-dom';
2
28
  import { Component as ComponentClass } from '../../base/Component';
3
29
  import { clamp, lerp } from '../../utils/math';
@@ -8,213 +34,282 @@ import { onResize } from '../../utils/internal/onResize';
8
34
  /**
9
35
  * Smooth scrolling
10
36
  */
11
- export class SmoothScroll extends ComponentClass {
12
- _getDefaultProps() {
13
- return Object.assign(Object.assign({}, super._getDefaultProps()), { container: `#${this.prefix}`, elements: false, animationFrame: false, viewportTarget: 'any', resizeDebounce: 0, hasWillChange: true, translatePrecision: 2, isEnabled: true, hasWheel: true, direction: 'vertical', isInverseHandlerDirection: false, isAutoStop: true, hasStopPropagation: true, lerp: 0.1, isFpsNormalized: true, lerpApproximation: 0.1 });
14
- }
15
- get prefix() {
16
- return `${this.app.prefix}smooth-scroll`;
17
- }
18
- /** Scroll container */
19
- get container() {
20
- return this._container;
21
- }
22
- /**
23
- * Scroll wrapper. If the element does not exist indide the `container`,
24
- * it will be created automatically
25
- */
26
- get wrapper() {
27
- return this._elements.wrapper;
28
- }
29
- /** `scrollLeft` target value */
30
- get targetLeft() {
31
- return this._targetLeft;
32
- }
33
- set targetLeft(value) {
34
- this.setTargetLeft(value);
35
- this._enable();
36
- }
37
- /** Update `targetLeft` without animation */
38
- setTargetLeft(value) {
39
- this._targetLeft = clamp(value, [0, this.maxScrollableWidth]);
40
- }
41
- /** `scrollTop` target value */
42
- get targetTop() {
43
- return this._targetTop;
44
- }
45
- set targetTop(value) {
46
- this.setTargetTop(value);
47
- this._enable();
48
- }
49
- /** Update `targetTop` without animation */
50
- setTargetTop(value) {
51
- this._targetTop = clamp(value, [0, this.maxScrollableHeight]);
52
- }
53
- /** `scrollLeft` */
54
- get scrollLeft() {
55
- return this._scrollLeft;
56
- }
57
- set scrollLeft(value) {
58
- this.setTargetLeft(value);
59
- this._scrollLeft = this._targetLeft;
60
- this._enable();
61
- }
62
- /** `scrollTop` */
63
- get scrollTop() {
64
- return this._scrollTop;
65
- }
66
- set scrollTop(value) {
67
- this.setTargetTop(value);
68
- this._scrollTop = this._targetTop;
69
- this._enable();
70
- }
71
- /** Scroll width */
72
- get scrollWidth() {
73
- return this._scrollWidth;
74
- }
75
- /** Scroll height */
76
- get scrollHeight() {
77
- return this._scrollHeight;
78
- }
79
- /** Container width */
80
- get clientWidth() {
81
- return this._clientWidth;
82
- }
83
- /** Container height */
84
- get clientHeight() {
85
- return this._clientHeight;
86
- }
87
- /** Maximum scrollable area of the X axis */
88
- get maxScrollableWidth() {
89
- return this.scrollWidth - this.clientWidth;
90
- }
91
- /** Maximum scrollable area of the Y axis */
92
- get maxScrollableHeight() {
93
- return this.scrollHeight - this.clientHeight;
94
- }
95
- /** Has scroll */
96
- get hasScroll() {
97
- return this.maxScrollableHeight > 0 || this.maxScrollableWidth > 0;
98
- }
99
- get isSmoothScroll() {
100
- return true;
101
- }
102
- constructor(initialProps, canInit = true) {
103
- super(initialProps, false);
37
+ var SmoothScroll = /** @class */ (function (_super) {
38
+ __extends(SmoothScroll, _super);
39
+ function SmoothScroll(initialProps, canInit) {
40
+ if (canInit === void 0) { canInit = true; }
41
+ var _this = _super.call(this, initialProps, false) || this;
104
42
  // set default variables
105
- this._targetLeft = 0;
106
- this._targetTop = 0;
107
- this._scrollLeft = 0;
108
- this._scrollTop = 0;
109
- this._scrollWidth = 0;
110
- this._scrollHeight = 0;
111
- this._clientWidth = 0;
112
- this._clientHeight = 0;
113
- this._wrapperWidth = 0;
114
- this._wrapperHeight = 0;
115
- this._frameIndex = 0;
116
- this._isEqualLerp = false;
117
- const { container, elements, hasWillChange, animationFrame, translatePrecision, } = this.props;
43
+ _this._targetLeft = 0;
44
+ _this._targetTop = 0;
45
+ _this._scrollLeft = 0;
46
+ _this._scrollTop = 0;
47
+ _this._scrollWidth = 0;
48
+ _this._scrollHeight = 0;
49
+ _this._clientWidth = 0;
50
+ _this._clientHeight = 0;
51
+ _this._wrapperWidth = 0;
52
+ _this._wrapperHeight = 0;
53
+ _this._frameIndex = 0;
54
+ _this._isEqualLerp = false;
55
+ var _a = _this.props, container = _a.container, elements = _a.elements, hasWillChange = _a.hasWillChange, animationFrame = _a.animationFrame, translatePrecision = _a.translatePrecision;
118
56
  // get outer elements
119
- this._container = selectOne(container);
120
- if (!(this._container instanceof HTMLElement)) {
121
- throw new Error(`${container} is not a HTMLElement`);
57
+ _this._container = selectOne(container);
58
+ if (!(_this._container instanceof HTMLElement)) {
59
+ throw new Error("".concat(container, " is not a HTMLElement"));
122
60
  }
123
- this.toggleClassName(this._container, this.className(''), true);
61
+ _this.toggleClassName(_this._container, _this.className(''), true);
124
62
  // create elements
125
- this._elements = new Elements({
126
- container: this._container,
127
- wrapperClassName: this.className('__wrapper'),
128
- elements,
129
- hasWillChange,
130
- translatePrecision,
63
+ _this._elements = new Elements({
64
+ container: _this._container,
65
+ wrapperClassName: _this.className('__wrapper'),
66
+ elements: elements,
67
+ hasWillChange: hasWillChange,
68
+ translatePrecision: translatePrecision,
131
69
  });
132
70
  // set classnames
133
- this._setDirectionClassNames(true);
71
+ _this._setDirectionClassNames(true);
134
72
  // create animation frame
135
- this._animationFrame = new AnimationFrame({
136
- callback: () => this.render(),
73
+ _this._animationFrame = new AnimationFrame({
74
+ callback: function () { return _this.render(); },
137
75
  outerAnimationFrame: animationFrame,
138
76
  });
139
77
  // initialize the class
140
78
  if (canInit) {
141
- this.init();
79
+ _this.init();
142
80
  }
143
- }
144
- _init() {
145
- super._init();
81
+ return _this;
82
+ }
83
+ SmoothScroll.prototype._getDefaultProps = function () {
84
+ return __assign(__assign({}, _super.prototype._getDefaultProps.call(this)), { container: "#".concat(this.prefix), elements: false, animationFrame: false, viewportTarget: 'any', resizeDebounce: 0, hasWillChange: true, translatePrecision: 2, isEnabled: true, hasWheel: true, direction: 'vertical', isInverseHandlerDirection: false, isAutoStop: true, hasStopPropagation: true, lerp: 0.1, isFpsNormalized: true, lerpApproximation: 0.1 });
85
+ };
86
+ Object.defineProperty(SmoothScroll.prototype, "prefix", {
87
+ get: function () {
88
+ return "".concat(this.app.prefix, "smooth-scroll");
89
+ },
90
+ enumerable: false,
91
+ configurable: true
92
+ });
93
+ Object.defineProperty(SmoothScroll.prototype, "container", {
94
+ /** Scroll container */
95
+ get: function () {
96
+ return this._container;
97
+ },
98
+ enumerable: false,
99
+ configurable: true
100
+ });
101
+ Object.defineProperty(SmoothScroll.prototype, "wrapper", {
102
+ /**
103
+ * Scroll wrapper. If the element does not exist indide the `container`,
104
+ * it will be created automatically
105
+ */
106
+ get: function () {
107
+ return this._elements.wrapper;
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ Object.defineProperty(SmoothScroll.prototype, "targetLeft", {
113
+ /** `scrollLeft` target value */
114
+ get: function () {
115
+ return this._targetLeft;
116
+ },
117
+ set: function (value) {
118
+ this.setTargetLeft(value);
119
+ this._enable();
120
+ },
121
+ enumerable: false,
122
+ configurable: true
123
+ });
124
+ /** Update `targetLeft` without animation */
125
+ SmoothScroll.prototype.setTargetLeft = function (value) {
126
+ this._targetLeft = clamp(value, [0, this.maxScrollableWidth]);
127
+ };
128
+ Object.defineProperty(SmoothScroll.prototype, "targetTop", {
129
+ /** `scrollTop` target value */
130
+ get: function () {
131
+ return this._targetTop;
132
+ },
133
+ set: function (value) {
134
+ this.setTargetTop(value);
135
+ this._enable();
136
+ },
137
+ enumerable: false,
138
+ configurable: true
139
+ });
140
+ /** Update `targetTop` without animation */
141
+ SmoothScroll.prototype.setTargetTop = function (value) {
142
+ this._targetTop = clamp(value, [0, this.maxScrollableHeight]);
143
+ };
144
+ Object.defineProperty(SmoothScroll.prototype, "scrollLeft", {
145
+ /** `scrollLeft` */
146
+ get: function () {
147
+ return this._scrollLeft;
148
+ },
149
+ set: function (value) {
150
+ this.setTargetLeft(value);
151
+ this._scrollLeft = this._targetLeft;
152
+ this._enable();
153
+ },
154
+ enumerable: false,
155
+ configurable: true
156
+ });
157
+ Object.defineProperty(SmoothScroll.prototype, "scrollTop", {
158
+ /** `scrollTop` */
159
+ get: function () {
160
+ return this._scrollTop;
161
+ },
162
+ set: function (value) {
163
+ this.setTargetTop(value);
164
+ this._scrollTop = this._targetTop;
165
+ this._enable();
166
+ },
167
+ enumerable: false,
168
+ configurable: true
169
+ });
170
+ Object.defineProperty(SmoothScroll.prototype, "scrollWidth", {
171
+ /** Scroll width */
172
+ get: function () {
173
+ return this._scrollWidth;
174
+ },
175
+ enumerable: false,
176
+ configurable: true
177
+ });
178
+ Object.defineProperty(SmoothScroll.prototype, "scrollHeight", {
179
+ /** Scroll height */
180
+ get: function () {
181
+ return this._scrollHeight;
182
+ },
183
+ enumerable: false,
184
+ configurable: true
185
+ });
186
+ Object.defineProperty(SmoothScroll.prototype, "clientWidth", {
187
+ /** Container width */
188
+ get: function () {
189
+ return this._clientWidth;
190
+ },
191
+ enumerable: false,
192
+ configurable: true
193
+ });
194
+ Object.defineProperty(SmoothScroll.prototype, "clientHeight", {
195
+ /** Container height */
196
+ get: function () {
197
+ return this._clientHeight;
198
+ },
199
+ enumerable: false,
200
+ configurable: true
201
+ });
202
+ Object.defineProperty(SmoothScroll.prototype, "maxScrollableWidth", {
203
+ /** Maximum scrollable area of the X axis */
204
+ get: function () {
205
+ return this.scrollWidth - this.clientWidth;
206
+ },
207
+ enumerable: false,
208
+ configurable: true
209
+ });
210
+ Object.defineProperty(SmoothScroll.prototype, "maxScrollableHeight", {
211
+ /** Maximum scrollable area of the Y axis */
212
+ get: function () {
213
+ return this.scrollHeight - this.clientHeight;
214
+ },
215
+ enumerable: false,
216
+ configurable: true
217
+ });
218
+ Object.defineProperty(SmoothScroll.prototype, "hasScroll", {
219
+ /** Has scroll */
220
+ get: function () {
221
+ return this.maxScrollableHeight > 0 || this.maxScrollableWidth > 0;
222
+ },
223
+ enumerable: false,
224
+ configurable: true
225
+ });
226
+ Object.defineProperty(SmoothScroll.prototype, "isSmoothScroll", {
227
+ get: function () {
228
+ return true;
229
+ },
230
+ enumerable: false,
231
+ configurable: true
232
+ });
233
+ SmoothScroll.prototype._init = function () {
234
+ _super.prototype._init.call(this);
146
235
  this._setEvents();
147
236
  this._toggle();
148
- }
149
- _setDirectionClassNames(isActive) {
150
- const { direction } = this.props;
151
- const isHorizontal = direction === 'horizontal' && isActive;
152
- const isVertical = direction === 'vertical' && isActive;
237
+ };
238
+ SmoothScroll.prototype._setDirectionClassNames = function (isActive) {
239
+ var direction = this.props.direction;
240
+ var isHorizontal = direction === 'horizontal' && isActive;
241
+ var isVertical = direction === 'vertical' && isActive;
153
242
  this.wrapper.classList.toggle(this.className('_horizontal'), isHorizontal);
154
243
  this.wrapper.classList.toggle(this.className('_vertical'), isVertical);
155
- }
244
+ };
156
245
  /** Set events */
157
- _setEvents() {
246
+ SmoothScroll.prototype._setEvents = function () {
247
+ var _this = this;
158
248
  this._setResize();
159
249
  // wheel
160
- this.addEventListener(this.container, 'wheel', (event) => this.handleWheel(event));
250
+ this.addEventListener(this.container, 'wheel', function (event) {
251
+ return _this.handleWheel(event);
252
+ });
161
253
  // prevent native scroll
162
- this.addEventListener(this.container, 'scroll', () => {
163
- this.container.scrollTop = 0;
164
- this.container.scrollLeft = 0;
254
+ this.addEventListener(this.container, 'scroll', function () {
255
+ _this.container.scrollTop = 0;
256
+ _this.container.scrollLeft = 0;
165
257
  });
166
- }
258
+ };
167
259
  /** Set resize events */
168
- _setResize() {
169
- const { viewportTarget, resizeDebounce } = this.props;
260
+ SmoothScroll.prototype._setResize = function () {
261
+ var _this = this;
262
+ var _a = this.props, viewportTarget = _a.viewportTarget, resizeDebounce = _a.resizeDebounce;
170
263
  // resize handler
171
- const resizeHandler = onResize({
172
- onResize: () => this.resize(true),
264
+ var resizeHandler = onResize({
265
+ onResize: function () { return _this.resize(true); },
173
266
  element: [this.container, this.wrapper],
174
- viewportTarget,
175
- resizeDebounce,
267
+ viewportTarget: viewportTarget,
268
+ resizeDebounce: resizeDebounce,
176
269
  });
177
- this.addDestroyableAction(() => resizeHandler.remove());
270
+ this.addDestroyableAction(function () { return resizeHandler.remove(); });
178
271
  // initial resize
179
272
  resizeHandler.resize();
180
273
  // if resize observer not used, we recalculate sizes on each 10th frame
181
274
  if (!resizeHandler.hasResizeObserver) {
182
- this.addCallback('render', (() => {
183
- if (this._frameIndex % 10 === 0) {
184
- this._recalculateScrollSizes();
275
+ this.addCallback('render', (function () {
276
+ if (_this._frameIndex % 10 === 0) {
277
+ _this._recalculateScrollSizes();
185
278
  }
186
279
  }), { isProtected: true, name: this.name });
187
280
  }
188
- }
281
+ };
189
282
  /** Handle properties mutation */
190
- _onPropsMutate() {
191
- super._onPropsMutate();
283
+ SmoothScroll.prototype._onPropsMutate = function () {
284
+ _super.prototype._onPropsMutate.call(this);
192
285
  this._setDirectionClassNames(true);
193
286
  this.resize();
194
287
  this._toggle();
195
- }
288
+ };
196
289
  /** Recalculate scroll sizes */
197
- _recalculateScrollSizes() {
198
- const { wrapper } = this;
199
- const height = wrapper.clientHeight;
200
- const width = wrapper.clientWidth;
290
+ SmoothScroll.prototype._recalculateScrollSizes = function () {
291
+ var wrapper = this.wrapper;
292
+ var height = wrapper.clientHeight;
293
+ var width = wrapper.clientWidth;
201
294
  if (height !== this._wrapperHeight || width !== this._wrapperWidth) {
202
295
  this.resize(false);
203
296
  }
204
- }
297
+ };
205
298
  /** Resize the scene */
206
- resize(isNative = false) {
299
+ SmoothScroll.prototype.resize = function (isNative) {
300
+ if (isNative === void 0) { isNative = false; }
207
301
  this._resize(isNative);
208
302
  // launch callbacks
209
303
  this.callbacks.tbt('resize', undefined);
210
304
  // enable animation
211
305
  this._enable();
212
- }
306
+ };
213
307
  /** Resize the scene */
214
- _resize(
308
+ SmoothScroll.prototype._resize = function (
215
309
  /** If the method was called natively on window resize */
216
- isNative = false) {
217
- const { container, wrapper } = this;
310
+ isNative) {
311
+ if (isNative === void 0) { isNative = false; }
312
+ var _a = this, container = _a.container, wrapper = _a.wrapper;
218
313
  this._clientWidth = container.clientWidth;
219
314
  this._clientHeight = container.clientHeight;
220
315
  this._wrapperWidth = wrapper.clientWidth;
@@ -241,14 +336,14 @@ export class SmoothScroll extends ComponentClass {
241
336
  container.classList.toggle(this.className('_no-scroll'), !this.hasScroll);
242
337
  // update elements
243
338
  this._elements.updateElementsProp(this.scrollLeft, this.scrollTop);
244
- }
339
+ };
245
340
  /** Event on wheel */
246
- handleWheel(event) {
247
- const { isEnabled, hasWheel, hasStopPropagation, isInverseHandlerDirection, } = this.props;
341
+ SmoothScroll.prototype.handleWheel = function (event) {
342
+ var _a = this.props, isEnabled = _a.isEnabled, hasWheel = _a.hasWheel, hasStopPropagation = _a.hasStopPropagation, isInverseHandlerDirection = _a.isInverseHandlerDirection;
248
343
  if (!isEnabled || !hasWheel || !this.hasScroll) {
249
344
  return;
250
345
  }
251
- const isPropagationStopped = hasStopPropagation ||
346
+ var isPropagationStopped = hasStopPropagation ||
252
347
  (this.scrollTop > 0 && this.scrollTop < this.maxScrollableHeight) ||
253
348
  (this.scrollLeft > 0 && this.scrollLeft < this.maxScrollableWidth);
254
349
  if (isPropagationStopped) {
@@ -257,39 +352,39 @@ export class SmoothScroll extends ComponentClass {
257
352
  event.preventDefault();
258
353
  }
259
354
  // get normalized delta
260
- const { pixelX, pixelY } = normalizeWheel(event);
355
+ var _b = normalizeWheel(event), pixelX = _b.pixelX, pixelY = _b.pixelY;
261
356
  // set new scroll targets
262
- const leftIterator = isInverseHandlerDirection ? pixelY : pixelX;
263
- const topIterator = isInverseHandlerDirection ? pixelX : pixelY;
357
+ var leftIterator = isInverseHandlerDirection ? pixelY : pixelX;
358
+ var topIterator = isInverseHandlerDirection ? pixelX : pixelY;
264
359
  this.setTargetLeft(this.targetLeft + leftIterator);
265
360
  this.setTargetTop(this.targetTop + topIterator);
266
361
  // play animation frame
267
362
  this._enable();
268
363
  // launch events
269
- this.callbacks.tbt('wheel', { event });
270
- }
364
+ this.callbacks.tbt('wheel', { event: event });
365
+ };
271
366
  /** Toggle animation: Enable / Disable scrolling */
272
- _toggle() {
367
+ SmoothScroll.prototype._toggle = function () {
273
368
  if (this.props.isEnabled) {
274
369
  this._enable();
275
370
  }
276
371
  else {
277
372
  this._disable();
278
373
  }
279
- }
374
+ };
280
375
  /** Enable scrolling */
281
- _enable() {
376
+ SmoothScroll.prototype._enable = function () {
282
377
  if (!this.props.isEnabled) {
283
378
  return;
284
379
  }
285
380
  this._animationFrame.enable();
286
- }
381
+ };
287
382
  /** Disable scrolling */
288
- _disable() {
383
+ SmoothScroll.prototype._disable = function () {
289
384
  this._animationFrame.disable();
290
- }
385
+ };
291
386
  /** Render elements */
292
- render() {
387
+ SmoothScroll.prototype.render = function () {
293
388
  this._frameIndex += 1;
294
389
  this._calcScrollValues();
295
390
  this._calcElementsValues();
@@ -304,56 +399,58 @@ export class SmoothScroll extends ComponentClass {
304
399
  this.callbacks.tbt('render', undefined);
305
400
  // auto stop
306
401
  this._checkAutoStop();
307
- }
402
+ };
308
403
  /** Calculate scroll values */
309
- _calcScrollValues() {
404
+ SmoothScroll.prototype._calcScrollValues = function () {
310
405
  this._scrollLeft = this._lerp(this.scrollLeft, this.targetLeft);
311
406
  this._scrollTop = this._lerp(this.scrollTop, this.targetTop);
312
- }
407
+ };
313
408
  /** Calculate elements' values */
314
- _calcElementsValues() {
315
- const { elements } = this._elements;
316
- for (let index = 0; index < elements.length; index += 1) {
317
- const element = elements[index];
318
- const elementLerp = this._getLerp(element);
409
+ SmoothScroll.prototype._calcElementsValues = function () {
410
+ var elements = this._elements.elements;
411
+ for (var index = 0; index < elements.length; index += 1) {
412
+ var element = elements[index];
413
+ var elementLerp = this._getLerp(element);
319
414
  element.smoothScrollLeft = this._lerp(element.smoothScrollLeft, this._targetLeft, elementLerp);
320
415
  element.smoothScrollTop = this._lerp(element.smoothScrollTop, this._targetTop, elementLerp);
321
416
  }
322
- }
417
+ };
323
418
  /** Make auto stop if the target and current values are equal */
324
- _checkAutoStop() {
419
+ SmoothScroll.prototype._checkAutoStop = function () {
325
420
  if (!this.props.isAutoStop) {
326
421
  return;
327
422
  }
328
- const yDiff = Math.abs(this.targetTop - this.scrollTop);
329
- const xDiff = Math.abs(this.targetLeft - this.scrollLeft);
330
- const isGlobalInterpolated = xDiff === 0 && yDiff === 0;
331
- const isInnerInterpolated = this._elements.checkAllScrollValuesEqual();
423
+ var yDiff = Math.abs(this.targetTop - this.scrollTop);
424
+ var xDiff = Math.abs(this.targetLeft - this.scrollLeft);
425
+ var isGlobalInterpolated = xDiff === 0 && yDiff === 0;
426
+ var isInnerInterpolated = this._elements.checkAllScrollValuesEqual();
332
427
  if (isGlobalInterpolated && isInnerInterpolated) {
333
428
  this._disable();
334
429
  }
335
- }
430
+ };
336
431
  /** Interpolate values */
337
- _lerp(current, target, ease = this._getLerp()) {
338
- const { lerpApproximation } = this.props;
339
- const currentEase = this._isInstant ? 1 : ease;
340
- const value = lerp(current, target, currentEase, lerpApproximation);
432
+ SmoothScroll.prototype._lerp = function (current, target, ease) {
433
+ if (ease === void 0) { ease = this._getLerp(); }
434
+ var lerpApproximation = this.props.lerpApproximation;
435
+ var currentEase = this._isInstant ? 1 : ease;
436
+ var value = lerp(current, target, currentEase, lerpApproximation);
341
437
  return value;
342
- }
438
+ };
343
439
  /** Get lerp */
344
- _getLerp(element) {
440
+ SmoothScroll.prototype._getLerp = function (element) {
345
441
  var _a;
346
- const { lerp: lerpEase, isFpsNormalized } = this.props;
347
- const fpsMultiplier = isFpsNormalized
442
+ var _b = this.props, lerpEase = _b.lerp, isFpsNormalized = _b.isFpsNormalized;
443
+ var fpsMultiplier = isFpsNormalized
348
444
  ? this._animationFrame.easeMultiplier
349
445
  : 1;
350
446
  if (this._isEqualLerp || !element) {
351
447
  return lerpEase * fpsMultiplier;
352
448
  }
353
449
  return ((_a = element.smoothScrollLerp) !== null && _a !== void 0 ? _a : lerpEase) * fpsMultiplier;
354
- }
450
+ };
355
451
  /** Scroll to */
356
- scrollTo({ top, left, behavior }) {
452
+ SmoothScroll.prototype.scrollTo = function (_a) {
453
+ var top = _a.top, left = _a.left, behavior = _a.behavior;
357
454
  if (typeof left !== 'undefined') {
358
455
  if (behavior === 'smooth') {
359
456
  this.setTargetLeft(left);
@@ -375,16 +472,18 @@ export class SmoothScroll extends ComponentClass {
375
472
  if (behavior === 'smooth') {
376
473
  this._enable();
377
474
  }
378
- }
475
+ };
379
476
  /** Destroy the module */
380
- _destroy() {
381
- super._destroy();
477
+ SmoothScroll.prototype._destroy = function () {
478
+ _super.prototype._destroy.call(this);
382
479
  this._disable();
383
480
  this._elements.destroy();
384
481
  this._animationFrame.destroy();
385
482
  this._setDirectionClassNames(false);
386
483
  this._container.classList.remove(this.className('_has-scroll'));
387
484
  this._container.classList.remove(this.className('_no-scroll'));
388
- }
389
- }
485
+ };
486
+ return SmoothScroll;
487
+ }(ComponentClass));
488
+ export { SmoothScroll };
390
489
  //# sourceMappingURL=index.js.map