vevet 2.0.1-dev.2 → 2.0.1-dev.20

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 (96) hide show
  1. package/build/cdn/index.js +1 -1
  2. package/build/cjs/components/canvas/Ctx2DPrerender.js +20 -2
  3. package/build/cjs/components/loading/ProgressPreloader.js +14 -2
  4. package/build/cjs/components/page/Page.js +36 -8
  5. package/build/cjs/components/scroll/plugins/SmoothScrollDragPlugin.js +40 -5
  6. package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +9 -0
  7. package/build/cjs/components/scroll/scrollable/ScrollView.js +67 -53
  8. package/build/cjs/components/scroll/scrollbar/Bar.js +8 -2
  9. package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +11 -3
  10. package/build/cjs/components/text/SplitText.js +18 -2
  11. package/build/cjs/components/timeline/Timeline.js +1 -0
  12. package/build/cjs/handlers/wheel/WheelHandler.js +195 -0
  13. package/build/cjs/index.js +3 -1
  14. package/build/cjs/utils/listeners/onScroll.js +65 -25
  15. package/build/cjs/utils/math/index.js +5 -1
  16. package/build/cjs/utils/math/spreadScopeProgress.js +18 -0
  17. package/build/cjs/utils/math/wrap.js +13 -0
  18. package/build/es/app/Application.js +50 -93
  19. package/build/es/app/events/PageLoad.js +3 -7
  20. package/build/es/app/events/Viewport.js +10 -34
  21. package/build/es/base/Callbacks.js +8 -19
  22. package/build/es/base/Component.js +0 -1
  23. package/build/es/base/Module.js +41 -61
  24. package/build/es/base/MutableProp.js +10 -32
  25. package/build/es/base/Plugin.js +0 -1
  26. package/build/es/components/animation-frame/AnimationFrame.js +4 -28
  27. package/build/es/components/canvas/Ctx2D.js +21 -49
  28. package/build/es/components/canvas/Ctx2DPrerender.js +21 -7
  29. package/build/es/components/cursor/CustomCursor.js +25 -58
  30. package/build/es/components/dragger/Dragger.js +20 -41
  31. package/build/es/components/dragger/DraggerDirection.js +1 -4
  32. package/build/es/components/loading/Preloader.js +26 -41
  33. package/build/es/components/loading/ProgressPreloader.js +31 -38
  34. package/build/es/components/page/Page.js +46 -41
  35. package/build/es/components/scroll/plugins/SmoothScrollDragPlugin.js +47 -29
  36. package/build/es/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +9 -0
  37. package/build/es/components/scroll/scrollable/ScrollEventsBase.js +15 -22
  38. package/build/es/components/scroll/scrollable/ScrollView.js +62 -74
  39. package/build/es/components/scroll/scrollbar/Bar.js +43 -54
  40. package/build/es/components/scroll/scrollbar/ScrollBar.js +47 -73
  41. package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +63 -135
  42. package/build/es/components/text/SplitText.js +38 -43
  43. package/build/es/components/timeline/StaticTimeline.js +11 -22
  44. package/build/es/components/timeline/Timeline.js +13 -28
  45. package/build/es/handlers/wheel/WheelHandler.js +153 -0
  46. package/build/es/index.js +2 -1
  47. package/build/es/utils/listeners/onScroll.js +64 -25
  48. package/build/es/utils/math/index.js +3 -1
  49. package/build/es/utils/math/spreadScopeProgress.js +15 -0
  50. package/build/es/utils/math/wrap.js +10 -0
  51. package/build/types/components/canvas/Ctx2DPrerender.d.ts +1 -1
  52. package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -1
  53. package/build/types/components/loading/ProgressPreloader.d.ts +7 -0
  54. package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -1
  55. package/build/types/components/page/Page.d.ts +2 -0
  56. package/build/types/components/page/Page.d.ts.map +1 -1
  57. package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts +11 -0
  58. package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts.map +1 -1
  59. package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts.map +1 -1
  60. package/build/types/components/scroll/scrollable/ScrollView.d.ts +27 -13
  61. package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
  62. package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -1
  63. package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -1
  64. package/build/types/components/text/SplitText.d.ts +6 -0
  65. package/build/types/components/text/SplitText.d.ts.map +1 -1
  66. package/build/types/components/timeline/Timeline.d.ts.map +1 -1
  67. package/build/types/handlers/wheel/WheelHandler.d.ts +100 -0
  68. package/build/types/handlers/wheel/WheelHandler.d.ts.map +1 -0
  69. package/build/types/index.d.ts +2 -1
  70. package/build/types/index.d.ts.map +1 -1
  71. package/build/types/utils/listeners/onScroll.d.ts +13 -5
  72. package/build/types/utils/listeners/onScroll.d.ts.map +1 -1
  73. package/build/types/utils/math/index.d.ts +3 -1
  74. package/build/types/utils/math/index.d.ts.map +1 -1
  75. package/build/types/utils/math/spreadScopeProgress.d.ts +5 -0
  76. package/build/types/utils/math/spreadScopeProgress.d.ts.map +1 -0
  77. package/build/types/utils/math/wrap.d.ts +5 -0
  78. package/build/types/utils/math/wrap.d.ts.map +1 -0
  79. package/package.json +4 -3
  80. package/src/sass/components/cursor/_custom-cursor.scss +0 -1
  81. package/src/ts/components/canvas/Ctx2DPrerender.ts +23 -6
  82. package/src/ts/components/loading/ProgressPreloader.ts +21 -2
  83. package/src/ts/components/page/Page.ts +34 -8
  84. package/src/ts/components/scroll/plugins/SmoothScrollDragPlugin.ts +58 -5
  85. package/src/ts/components/scroll/plugins/SmoothScrollKeyboardPlugin.ts +12 -0
  86. package/src/ts/components/scroll/scrollable/ScrollView.ts +78 -64
  87. package/src/ts/components/scroll/scrollbar/Bar.ts +8 -2
  88. package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +12 -3
  89. package/src/ts/components/text/SplitText.ts +26 -1
  90. package/src/ts/components/timeline/Timeline.ts +1 -0
  91. package/src/ts/handlers/wheel/WheelHandler.ts +269 -0
  92. package/src/ts/index.ts +4 -0
  93. package/src/ts/utils/listeners/onScroll.ts +105 -34
  94. package/src/ts/utils/math/index.ts +4 -0
  95. package/src/ts/utils/math/spreadScopeProgress.ts +18 -0
  96. package/src/ts/utils/math/wrap.ts +18 -0
@@ -48,14 +48,32 @@ var Ctx2DPrerender = /** @class */ (function (_super) {
48
48
  this._prerender();
49
49
  };
50
50
  Ctx2DPrerender.prototype._prerender = function () {
51
+ // check if can render
52
+ if (this.width === 0 || this.height === 0) {
53
+ return;
54
+ }
51
55
  // check if media exists
52
56
  var media = this.prop.media;
53
57
  if (!media) {
54
58
  return;
55
59
  }
60
+ // get source info
61
+ var source;
62
+ var sourceWidth;
63
+ var sourceHeight;
64
+ if (media instanceof Ctx2D_1.Ctx2D) {
65
+ source = media.canvas;
66
+ sourceWidth = media.width;
67
+ sourceHeight = media.height;
68
+ }
69
+ else {
70
+ source = media;
71
+ }
56
72
  // get media sizes
57
73
  var size = get_image_pos_1.getPos({
58
- source: media,
74
+ source: source,
75
+ sourceWidth: sourceWidth,
76
+ sourceHeight: sourceHeight,
59
77
  rule: this.prop.posRule,
60
78
  scale: 1,
61
79
  width: this.width,
@@ -63,7 +81,7 @@ var Ctx2DPrerender = /** @class */ (function (_super) {
63
81
  });
64
82
  this._ctx.clearRect(0, 0, this.width, this.height);
65
83
  // render the media
66
- this._ctx.drawImage(media, 0, 0, size.sourceWidth, size.sourceHeight, size.x, size.y, size.width, size.height);
84
+ this._ctx.drawImage(source, size.x, size.y, size.width, size.height);
67
85
  // launch callbacks on prerender
68
86
  this.callbacks.tbt('prerender', false);
69
87
  };
@@ -62,6 +62,7 @@ var ProgressPreloader = /** @class */ (function (_super) {
62
62
  img: true,
63
63
  video: true,
64
64
  custom: '.js-preload',
65
+ ignoreClassName: 'js-preload-ignore',
65
66
  }, calc: {
66
67
  lerp: 0.1,
67
68
  forceEnd: 500,
@@ -192,6 +193,9 @@ var ProgressPreloader = /** @class */ (function (_super) {
192
193
  if (loaders.img) {
193
194
  var imgs = vevet_dom_1.selectAll('img');
194
195
  imgs.forEach(function (img) {
196
+ if (img.classList.contains(loaders.ignoreClassName)) {
197
+ return;
198
+ }
195
199
  _this._imgs.push(img);
196
200
  _this._resourcesTotal += 1;
197
201
  });
@@ -200,13 +204,21 @@ var ProgressPreloader = /** @class */ (function (_super) {
200
204
  if (loaders.video) {
201
205
  var videos = vevet_dom_1.selectAll('video');
202
206
  videos.forEach(function (video) {
207
+ if (video.classList.contains(loaders.ignoreClassName)) {
208
+ return;
209
+ }
203
210
  _this._videos.push(video);
204
211
  _this._resourcesTotal += 1;
205
212
  });
206
213
  }
207
214
  // get custom resources
208
215
  if (loaders.custom) {
209
- this._customResources = Array.from(vevet_dom_1.selectAll(loaders.custom));
216
+ this._customResources = Array.from(vevet_dom_1.selectAll(loaders.custom)).filter(function (el) {
217
+ if (el.classList.contains(loaders.ignoreClassName)) {
218
+ return false;
219
+ }
220
+ return true;
221
+ });
210
222
  this._resourcesTotal += this._customResources.length;
211
223
  }
212
224
  };
@@ -233,7 +245,7 @@ var ProgressPreloader = /** @class */ (function (_super) {
233
245
  img.addEventListener('error', function () {
234
246
  _this._handleLoadedResource();
235
247
  });
236
- image.src = img.src;
248
+ image.src = img.currentSrc || img.src;
237
249
  }
238
250
  });
239
251
  // preload videos
@@ -45,6 +45,7 @@ var Page = /** @class */ (function (_super) {
45
45
  if (init === void 0) { init = true; }
46
46
  var _this = _super.call(this, initialProp, false) || this;
47
47
  // set default vars
48
+ _this._blocked = false;
48
49
  _this._created = false;
49
50
  _this._shown = false;
50
51
  _this._hidden = false;
@@ -56,6 +57,13 @@ var Page = /** @class */ (function (_super) {
56
57
  }
57
58
  return _this;
58
59
  }
60
+ Object.defineProperty(Page.prototype, "blocked", {
61
+ get: function () {
62
+ return this._blocked;
63
+ },
64
+ enumerable: false,
65
+ configurable: true
66
+ });
59
67
  Object.defineProperty(Page.prototype, "created", {
60
68
  get: function () {
61
69
  return this._created;
@@ -103,11 +111,12 @@ var Page = /** @class */ (function (_super) {
103
111
  if (viaAJAX === void 0) { viaAJAX = false; }
104
112
  return new Promise(function (resolve, reject) {
105
113
  _this.canCreate().then(function () {
106
- if (_this.created) {
114
+ if (_this.created || _this.blocked) {
115
+ reject();
107
116
  return;
108
117
  }
109
118
  // update vars
110
- _this._created = true;
119
+ _this._blocked = true;
111
120
  _this._shown = false;
112
121
  _this._hidden = false;
113
122
  _this._destroyed = false;
@@ -119,7 +128,11 @@ var Page = /** @class */ (function (_super) {
119
128
  // actions
120
129
  _this._create().then(function () {
121
130
  _this.callbacks.tbt('create', false);
131
+ _this._blocked = false;
132
+ _this._created = true;
122
133
  resolve();
134
+ }).catch(function () {
135
+ reject();
123
136
  });
124
137
  }).catch(function () {
125
138
  reject();
@@ -154,18 +167,23 @@ var Page = /** @class */ (function (_super) {
154
167
  var _this = this;
155
168
  return new Promise(function (resolve, reject) {
156
169
  _this.canShow().then(function () {
157
- if (_this.shown) {
170
+ if (_this.shown || _this.blocked) {
171
+ reject();
158
172
  return;
159
173
  }
160
174
  // update vars
175
+ _this._blocked = true;
161
176
  _this._created = true;
162
- _this._shown = true;
163
177
  _this._hidden = false;
164
178
  _this._destroyed = false;
165
179
  // actions
166
180
  _this._show().then(function () {
167
181
  _this.callbacks.tbt('show', false);
182
+ _this._blocked = false;
183
+ _this._shown = true;
168
184
  resolve();
185
+ }).catch(function () {
186
+ reject();
169
187
  });
170
188
  // launch events
171
189
  }).catch(function () {
@@ -201,18 +219,23 @@ var Page = /** @class */ (function (_super) {
201
219
  var _this = this;
202
220
  return new Promise(function (resolve, reject) {
203
221
  _this.canHide().then(function () {
204
- if (_this.hidden) {
222
+ if (_this.hidden || _this.blocked) {
223
+ reject();
205
224
  return;
206
225
  }
207
226
  // update vars
227
+ _this._blocked = true;
208
228
  _this._created = true;
209
229
  _this._shown = false;
210
- _this._hidden = true;
211
230
  _this._destroyed = false;
212
231
  // actions
213
232
  _this._hide().then(function () {
214
233
  _this.callbacks.tbt('hide', false);
234
+ _this._blocked = false;
235
+ _this._hidden = true;
215
236
  resolve();
237
+ }).catch(function () {
238
+ reject();
216
239
  });
217
240
  }).catch(function () {
218
241
  reject();
@@ -247,21 +270,26 @@ var Page = /** @class */ (function (_super) {
247
270
  var _this = this;
248
271
  return new Promise(function (resolve, reject) {
249
272
  _this.canDestroy().then(function () {
250
- if (_this.destroyed) {
273
+ if (_this.destroyed || _this.blocked) {
274
+ reject();
251
275
  return;
252
276
  }
253
277
  // change vars
278
+ _this._blocked = true;
254
279
  _this._created = false;
255
280
  _this._shown = false;
256
281
  _this._hidden = true;
257
- _this._destroyed = true;
258
282
  // update page
259
283
  _this._app.page = false;
260
284
  // remove page class
261
285
  _this._app.html.classList.remove(_this.pageClassName);
262
286
  // actions
263
287
  _this._destroy().then(function () {
288
+ _this._blocked = false;
289
+ _this._destroyed = true;
264
290
  resolve();
291
+ }).catch(function () {
292
+ reject();
265
293
  });
266
294
  }).catch(function () {
267
295
  reject();
@@ -37,12 +37,13 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
37
37
  __extends(SmoothScrollDragPlugin, _super);
38
38
  function SmoothScrollDragPlugin(initialProp) {
39
39
  var _this = _super.call(this, initialProp) || this;
40
+ _this._dragger = undefined;
40
41
  _this._componentEvents = [];
41
42
  _this._currentLerp = false;
42
43
  return _this;
43
44
  }
44
45
  SmoothScrollDragPlugin.prototype._getDefaultProp = function () {
45
- return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { enabled: true, speed: 1, lerp: false, reverseDir: false });
46
+ return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { enabled: true, speed: 1, lerp: false, reverseDir: false, stopPropagation: false });
46
47
  };
47
48
  Object.defineProperty(SmoothScrollDragPlugin.prototype, "isDragging", {
48
49
  /**
@@ -89,7 +90,9 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
89
90
  container: component.outer,
90
91
  });
91
92
  this._dragger.addCallback('start', this._handleDragStart.bind(this));
92
- this._dragger.addCallback('move', this._handleDragMove.bind(this));
93
+ this._dragger.addCallback('move', function (data) {
94
+ _this._handleDragMove(data);
95
+ });
93
96
  this._dragger.addCallback('end', this._handleDragEnd.bind(this));
94
97
  this._componentEvents.push(component.addCallback('wheel', function () {
95
98
  var _a;
@@ -118,9 +121,10 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
118
121
  if (!component.prop.enabled) {
119
122
  return;
120
123
  }
121
- // set classes
122
- component.outer.classList.add(draggingClassName);
123
- component.container.classList.add(draggingClassName);
124
+ // check scrollable area
125
+ if (component.maxScrollableWidth <= 0 && component.maxScrollableHeight <= 0) {
126
+ return;
127
+ }
124
128
  // change lerp
125
129
  var lerp = this.prop.lerp;
126
130
  if (typeof lerp !== 'boolean') {
@@ -131,6 +135,8 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
131
135
  },
132
136
  });
133
137
  }
138
+ // launch events
139
+ this._callbacks.tbt('start', false);
134
140
  };
135
141
  /**
136
142
  * Callback on dragging move
@@ -140,6 +146,28 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
140
146
  if (!component.prop.enabled) {
141
147
  return;
142
148
  }
149
+ // check scrollable area
150
+ if (component.maxScrollableWidth <= 0 && component.maxScrollableHeight <= 0) {
151
+ return;
152
+ }
153
+ var evt = data.evt;
154
+ // get difference between coordinates and decide
155
+ // if we need to stop propagation
156
+ var stopPropagation = this.prop.stopPropagation;
157
+ if (stopPropagation) {
158
+ if (!evt.cancelable) {
159
+ return;
160
+ }
161
+ var diffX = Math.abs(data.coords.x - data.start.x);
162
+ var diffY = Math.abs(data.coords.y - data.start.y);
163
+ if (((diffX > stopPropagation.threshold) && stopPropagation.dir === 'x')
164
+ || ((diffY > stopPropagation.threshold) && stopPropagation.dir === 'y')) {
165
+ if (evt.cancelable) {
166
+ evt.preventDefault();
167
+ evt.stopPropagation();
168
+ }
169
+ }
170
+ }
143
171
  var _a = this.prop, speed = _a.speed, reverseDir = _a.reverseDir;
144
172
  // get coordinates
145
173
  var x = data.step.x * speed;
@@ -147,6 +175,11 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
147
175
  // update scroll values
148
176
  component.targetLeft -= !reverseDir ? x : y;
149
177
  component.targetTop -= !reverseDir ? y : x;
178
+ // set classes
179
+ component.outer.classList.add(draggingClassName);
180
+ component.container.classList.add(draggingClassName);
181
+ // launch events
182
+ this._callbacks.tbt('move', false);
150
183
  };
151
184
  /**
152
185
  * Callback on dragging end
@@ -165,6 +198,8 @@ var SmoothScrollDragPlugin = /** @class */ (function (_super) {
165
198
  });
166
199
  this._currentLerp = false;
167
200
  }
201
+ // launch events
202
+ this._callbacks.tbt('end', false);
168
203
  };
169
204
  /**
170
205
  * Destroy the plugin
@@ -59,6 +59,15 @@ var SmoothScrollKeyboardPlugin = /** @class */ (function (_super) {
59
59
  return;
60
60
  }
61
61
  }
62
+ // check if the scroll container is in viewport
63
+ var viewport = this._app.viewport;
64
+ var bounding = component.outer.getBoundingClientRect();
65
+ if (!(bounding.left < viewport.width
66
+ && bounding.right > 0
67
+ && bounding.top < viewport.height
68
+ && bounding.bottom > 0)) {
69
+ return;
70
+ }
62
71
  // update scroll values
63
72
  var scrollIterator = 40;
64
73
  switch (e.keyCode) {
@@ -25,12 +25,16 @@ var __assign = (this && this.__assign) || function () {
25
25
  };
26
26
  return __assign.apply(this, arguments);
27
27
  };
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
29
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
30
+ to[j] = from[i];
31
+ return to;
32
+ };
28
33
  var __importDefault = (this && this.__importDefault) || function (mod) {
29
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
35
  };
31
36
  Object.defineProperty(exports, "__esModule", { value: true });
32
37
  exports.ScrollView = void 0;
33
- var vevet_dom_1 = require("vevet-dom");
34
38
  var ScrollEventsBase_1 = require("./ScrollEventsBase");
35
39
  var onScroll_1 = __importDefault(require("../../../utils/listeners/onScroll"));
36
40
  var listeners_1 = require("../../../utils/listeners");
@@ -44,9 +48,10 @@ var ScrollView = /** @class */ (function (_super) {
44
48
  function ScrollView(initialProp, init) {
45
49
  if (init === void 0) { init = true; }
46
50
  var _this = _super.call(this, initialProp, false) || this;
51
+ _this._scrollEvent = undefined;
52
+ _this._intersectionObserver = undefined;
47
53
  _this._firstStart = true;
48
- // get view elements
49
- _this.updateElements();
54
+ _this._elements = __spreadArray([], _this.prop.elements);
50
55
  // initialize the class
51
56
  if (init) {
52
57
  _this.init();
@@ -61,11 +66,20 @@ var ScrollView = /** @class */ (function (_super) {
61
66
  configurable: true
62
67
  });
63
68
  ScrollView.prototype._getDefaultProp = function () {
64
- return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: window, elements: "." + this.prefix + "__el", threshold: 0.9, states: 'in', classToToggle: 'viewed', useDelay: false, useIntersectionObserver: true });
69
+ return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { enabled: true, container: window, elements: [], threshold: 0.9, states: 'in', classToToggle: 'viewed', useDelay: false, useIntersectionObserver: true });
65
70
  };
71
+ Object.defineProperty(ScrollView.prototype, "elements", {
72
+ /**
73
+ * Elements to seek
74
+ */
75
+ get: function () {
76
+ return this._elements;
77
+ },
78
+ enumerable: false,
79
+ configurable: true
80
+ });
66
81
  ScrollView.prototype.init = function () {
67
82
  _super.prototype.init.call(this);
68
- this.seekBounding();
69
83
  };
70
84
  // Set Module Events
71
85
  ScrollView.prototype._setEvents = function () {
@@ -78,16 +92,17 @@ var ScrollView = /** @class */ (function (_super) {
78
92
  };
79
93
  ScrollView.prototype._onPropMutate = function () {
80
94
  _super.prototype._onPropMutate.call(this);
81
- this._removeViewEvents();
82
- this.updateElements();
83
- this._setViewEvents();
95
+ this.resize();
84
96
  };
85
97
  /**
86
98
  * Resize the scene
87
99
  */
88
100
  ScrollView.prototype.resize = function () {
89
101
  this._removeViewEvents();
90
- this._setViewEvents();
102
+ if (this.prop.enabled) {
103
+ this._setViewEvents();
104
+ this.seekBounding();
105
+ }
91
106
  };
92
107
  /**
93
108
  * Set View events: scroll or intersection
@@ -109,16 +124,17 @@ var ScrollView = /** @class */ (function (_super) {
109
124
  rootMargin: "0px " + xMargin + "px " + yMargin + "px 0px",
110
125
  });
111
126
  // add elements
112
- if (this.elements) {
113
- this.elements.forEach(function (el) {
114
- var _a;
115
- (_a = _this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
116
- });
117
- }
127
+ this.elements.forEach(function (el) {
128
+ var _a;
129
+ (_a = _this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
130
+ });
118
131
  }
119
132
  else {
120
133
  // set scroll bounding events
121
- this._scrollEvent = onScroll_1.default(this.prop.container, this._handleScroll.bind(this));
134
+ this._scrollEvent = onScroll_1.default({
135
+ container: this.prop.container,
136
+ callback: this._handleScroll.bind(this),
137
+ });
122
138
  }
123
139
  };
124
140
  /**
@@ -136,40 +152,6 @@ var ScrollView = /** @class */ (function (_super) {
136
152
  this._intersectionObserver = undefined;
137
153
  }
138
154
  };
139
- Object.defineProperty(ScrollView.prototype, "elements", {
140
- /**
141
- * Element to seek
142
- */
143
- get: function () {
144
- return this._elements;
145
- },
146
- enumerable: false,
147
- configurable: true
148
- });
149
- /**
150
- * Update elements
151
- */
152
- ScrollView.prototype.updateElements = function () {
153
- var _this = this;
154
- // check if elements exist
155
- if (typeof this.elements === 'undefined') {
156
- this._elements = [];
157
- }
158
- // unobserve old elements
159
- this.elements.forEach(function (el) {
160
- if (_this._intersectionObserver) {
161
- _this._intersectionObserver.unobserve(el);
162
- }
163
- });
164
- // update elements
165
- this._elements = Array.from(vevet_dom_1.selectAll(this.prop.elements, this.domParent || undefined)).filter(function (el) { return !el.classList.contains(_this.prop.classToToggle); });
166
- // add them to the observer
167
- this._elements.forEach(function (el) {
168
- if (_this._intersectionObserver) {
169
- _this._intersectionObserver.observe(el);
170
- }
171
- });
172
- };
173
155
  /**
174
156
  * Event on IntersectionObserver
175
157
  */
@@ -271,9 +253,11 @@ var ScrollView = /** @class */ (function (_super) {
271
253
  // update props
272
254
  el.scrollViewIn = inViewport;
273
255
  // toggle classes
274
- timeoutCallback_1.default(function () {
275
- el.classList.toggle(_this.prop.classToToggle, inViewport);
276
- }, delay);
256
+ if (this.prop.classToToggle) {
257
+ timeoutCallback_1.default(function () {
258
+ el.classList.toggle(_this.prop.classToToggle, inViewport);
259
+ }, delay);
260
+ }
277
261
  // process callbacks
278
262
  if (inViewport && (states === 'in' || states === 'inout')) {
279
263
  timeoutCallback_1.default(function () {
@@ -303,6 +287,36 @@ var ScrollView = /** @class */ (function (_super) {
303
287
  });
304
288
  this._elements = this._elements.filter(function (el) { return !el.scrollViewIn; });
305
289
  };
290
+ /**
291
+ * Add a view element
292
+ */
293
+ ScrollView.prototype.addElement = function (element) {
294
+ this._elements.push(element);
295
+ if (this._intersectionObserver) {
296
+ this._intersectionObserver.observe(element);
297
+ }
298
+ };
299
+ /**
300
+ * Remove a view element
301
+ */
302
+ ScrollView.prototype.removeElement = function (element) {
303
+ this._elements = this._elements.filter(function (el) { return el !== element; });
304
+ if (this._intersectionObserver) {
305
+ this._intersectionObserver.unobserve(element);
306
+ }
307
+ };
308
+ /**
309
+ * Remove all view elements
310
+ */
311
+ ScrollView.prototype.removeElements = function () {
312
+ var _this = this;
313
+ this._elements.forEach(function (el) {
314
+ if (_this._intersectionObserver) {
315
+ _this._intersectionObserver.unobserve(el);
316
+ }
317
+ });
318
+ this._elements = [];
319
+ };
306
320
  /**
307
321
  * Destroy the module
308
322
  */
@@ -22,6 +22,9 @@ var Bar = /** @class */ (function () {
22
22
  left: 0,
23
23
  top: 0,
24
24
  };
25
+ this._scrollEvent = undefined;
26
+ this._actionTimeout = undefined;
27
+ this._dragger = undefined;
25
28
  // create outer
26
29
  var outerClassNames = prefix + " " + prefix + "_" + dir;
27
30
  if (container instanceof Window) {
@@ -153,8 +156,11 @@ var Bar = /** @class */ (function () {
153
156
  this._listeners.push(vevet_dom_1.addEventListener(this.outer, 'mouseenter', this._handleHover.bind(this, true)));
154
157
  this._listeners.push(vevet_dom_1.addEventListener(this.outer, 'mouseleave', this._handleHover.bind(this, false)));
155
158
  // set scroll events
156
- this._scrollEvent = onScroll_1.default(this.prop.container, function (data) {
157
- _this._handleScroll(data);
159
+ this._scrollEvent = onScroll_1.default({
160
+ container: this.prop.container,
161
+ callback: function (data) {
162
+ _this._handleScroll(data);
163
+ },
158
164
  });
159
165
  // set dragger
160
166
  if (this.prop.isDraggable) {
@@ -55,6 +55,8 @@ var SmoothScroll = /** @class */ (function (_super) {
55
55
  _this._clientWidth = 0;
56
56
  _this._clientHeight = 0;
57
57
  _this._instant = false;
58
+ _this._animationFrame = undefined;
59
+ _this._outerAnimationFrameEvent = undefined;
58
60
  _this._currentFPS = 60;
59
61
  // get outer elements
60
62
  _this._outer = vevet_dom_1.selectOne(selectors.outer);
@@ -85,9 +87,11 @@ var SmoothScroll = /** @class */ (function (_super) {
85
87
  }
86
88
  _this._elementsLength = _this._elements.length;
87
89
  // add will-change
88
- _this._elements.forEach(function (el) {
89
- el.style.willChange = 'transform';
90
- });
90
+ if (_this.prop.useWillChange) {
91
+ _this._elements.forEach(function (el) {
92
+ el.style.willChange = 'transform';
93
+ });
94
+ }
91
95
  // initialize the class
92
96
  if (init) {
93
97
  _this.init();
@@ -320,6 +324,10 @@ var SmoothScroll = /** @class */ (function (_super) {
320
324
  this.targetLeft = parseInt(this.targetLeft.toFixed(0), 10);
321
325
  this.targetTop = parseInt(this.targetTop.toFixed(0), 10);
322
326
  }
327
+ // set scroll classes
328
+ var hasScroll = this.maxScrollableHeight > 0 || this.maxScrollableWidth > 0;
329
+ outer.classList.toggle('has-scroll', hasScroll);
330
+ outer.classList.toggle('no-scroll', !hasScroll);
323
331
  // render elements
324
332
  this._updateElementsProp();
325
333
  // this.render();
@@ -64,7 +64,7 @@ var SplitText = /** @class */ (function (_super) {
64
64
  return _this;
65
65
  }
66
66
  SplitText.prototype._getDefaultProp = function () {
67
- return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: "#" + this.prefix, appendLetters: true, appendLines: false });
67
+ return __assign(__assign({}, _super.prototype._getDefaultProp.call(this)), { container: "#" + this.prefix, appendLetters: true, appendLines: false, viewportTarget: '' });
68
68
  };
69
69
  Object.defineProperty(SplitText.prototype, "prefix", {
70
70
  get: function () {
@@ -110,7 +110,7 @@ var SplitText = /** @class */ (function (_super) {
110
110
  // split the text
111
111
  this.splitText();
112
112
  if (this.prop.appendLines) {
113
- this.addViewportCallback('', function () {
113
+ this.addViewportCallback(this.prop.viewportTarget, function () {
114
114
  _this.splitText();
115
115
  });
116
116
  }
@@ -157,6 +157,7 @@ var SplitText = /** @class */ (function (_super) {
157
157
  // get type of the char
158
158
  var charCode = char.charCodeAt(0);
159
159
  var isWhitespace = charCode === 32 || charCode === 160;
160
+ var isSeparator = [45, 8208, 8211, 8212, 8722].includes(charCode);
160
161
  var isNewLine = charCode === 10;
161
162
  // add elements
162
163
  if (isWhitespace) {
@@ -177,6 +178,21 @@ var SplitText = /** @class */ (function (_super) {
177
178
  if (!_this.prop.appendLetters) {
178
179
  currentWord.el.innerHTML = currentWord.content;
179
180
  }
181
+ // go to next word if needed
182
+ if (isSeparator) {
183
+ wordIndex += 1;
184
+ }
185
+ });
186
+ // only filled words
187
+ this._words = this._words.filter(function (word, index) {
188
+ if (word.content.length === 0) {
189
+ if (index > 0) {
190
+ _this._words[index - 1].whitespace = word.whitespace;
191
+ _this._words[index - 1].br = word.br;
192
+ }
193
+ return false;
194
+ }
195
+ return true;
180
196
  });
181
197
  };
182
198
  /**
@@ -44,6 +44,7 @@ var Timeline = /** @class */ (function (_super) {
44
44
  _this._isPlaying = false;
45
45
  _this._isReversed = false;
46
46
  _this._isPaused = false;
47
+ _this._animationFrame = undefined;
47
48
  _this._animationFrameLastTime = 0;
48
49
  if (init) {
49
50
  _this.init();