vevet 2.0.1-dev.14 → 2.0.1-dev.18

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 (25) hide show
  1. package/build/cdn/index.js +1 -1
  2. package/build/cjs/components/scroll/scrollable/ScrollView.js +65 -53
  3. package/build/cjs/components/scroll/scrollbar/Bar.js +5 -2
  4. package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +5 -3
  5. package/build/cjs/components/text/SplitText.js +2 -2
  6. package/build/cjs/utils/listeners/onScroll.js +66 -30
  7. package/build/es/components/scroll/scrollable/ScrollView.js +55 -48
  8. package/build/es/components/scroll/scrollbar/Bar.js +5 -2
  9. package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +5 -3
  10. package/build/es/components/text/SplitText.js +2 -2
  11. package/build/es/utils/listeners/onScroll.js +65 -30
  12. package/build/types/components/scroll/scrollable/ScrollView.d.ts +27 -13
  13. package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -1
  14. package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -1
  15. package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -1
  16. package/build/types/components/text/SplitText.d.ts +6 -0
  17. package/build/types/components/text/SplitText.d.ts.map +1 -1
  18. package/build/types/utils/listeners/onScroll.d.ts +10 -6
  19. package/build/types/utils/listeners/onScroll.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/src/ts/components/scroll/scrollable/ScrollView.ts +75 -64
  22. package/src/ts/components/scroll/scrollbar/Bar.ts +5 -2
  23. package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +5 -3
  24. package/src/ts/components/text/SplitText.ts +8 -1
  25. package/src/ts/utils/listeners/onScroll.ts +101 -41
@@ -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");
@@ -47,8 +51,7 @@ var ScrollView = /** @class */ (function (_super) {
47
51
  _this._scrollEvent = undefined;
48
52
  _this._intersectionObserver = undefined;
49
53
  _this._firstStart = true;
50
- // get view elements
51
- _this.updateElements();
54
+ _this._elements = __spreadArray([], _this.prop.elements);
52
55
  // initialize the class
53
56
  if (init) {
54
57
  _this.init();
@@ -63,11 +66,20 @@ var ScrollView = /** @class */ (function (_super) {
63
66
  configurable: true
64
67
  });
65
68
  ScrollView.prototype._getDefaultProp = function () {
66
- 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 });
67
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
+ });
68
81
  ScrollView.prototype.init = function () {
69
82
  _super.prototype.init.call(this);
70
- this.seekBounding();
71
83
  };
72
84
  // Set Module Events
73
85
  ScrollView.prototype._setEvents = function () {
@@ -80,16 +92,17 @@ var ScrollView = /** @class */ (function (_super) {
80
92
  };
81
93
  ScrollView.prototype._onPropMutate = function () {
82
94
  _super.prototype._onPropMutate.call(this);
83
- this._removeViewEvents();
84
- this.updateElements();
85
- this._setViewEvents();
95
+ this.resize();
86
96
  };
87
97
  /**
88
98
  * Resize the scene
89
99
  */
90
100
  ScrollView.prototype.resize = function () {
91
101
  this._removeViewEvents();
92
- this._setViewEvents();
102
+ if (this.prop.enabled) {
103
+ this._setViewEvents();
104
+ this.seekBounding();
105
+ }
93
106
  };
94
107
  /**
95
108
  * Set View events: scroll or intersection
@@ -111,16 +124,17 @@ var ScrollView = /** @class */ (function (_super) {
111
124
  rootMargin: "0px " + xMargin + "px " + yMargin + "px 0px",
112
125
  });
113
126
  // add elements
114
- if (this.elements) {
115
- this.elements.forEach(function (el) {
116
- var _a;
117
- (_a = _this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
118
- });
119
- }
127
+ this.elements.forEach(function (el) {
128
+ var _a;
129
+ (_a = _this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
130
+ });
120
131
  }
121
132
  else {
122
133
  // set scroll bounding events
123
- 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
+ });
124
138
  }
125
139
  };
126
140
  /**
@@ -138,40 +152,6 @@ var ScrollView = /** @class */ (function (_super) {
138
152
  this._intersectionObserver = undefined;
139
153
  }
140
154
  };
141
- Object.defineProperty(ScrollView.prototype, "elements", {
142
- /**
143
- * Element to seek
144
- */
145
- get: function () {
146
- return this._elements;
147
- },
148
- enumerable: false,
149
- configurable: true
150
- });
151
- /**
152
- * Update elements
153
- */
154
- ScrollView.prototype.updateElements = function () {
155
- var _this = this;
156
- // check if elements exist
157
- if (typeof this.elements === 'undefined') {
158
- this._elements = [];
159
- }
160
- // unobserve old elements
161
- this.elements.forEach(function (el) {
162
- if (_this._intersectionObserver) {
163
- _this._intersectionObserver.unobserve(el);
164
- }
165
- });
166
- // update elements
167
- this._elements = Array.from(vevet_dom_1.selectAll(this.prop.elements, this.domParent || undefined)).filter(function (el) { return !el.classList.contains(_this.prop.classToToggle); });
168
- // add them to the observer
169
- this._elements.forEach(function (el) {
170
- if (_this._intersectionObserver) {
171
- _this._intersectionObserver.observe(el);
172
- }
173
- });
174
- };
175
155
  /**
176
156
  * Event on IntersectionObserver
177
157
  */
@@ -273,9 +253,11 @@ var ScrollView = /** @class */ (function (_super) {
273
253
  // update props
274
254
  el.scrollViewIn = inViewport;
275
255
  // toggle classes
276
- timeoutCallback_1.default(function () {
277
- el.classList.toggle(_this.prop.classToToggle, inViewport);
278
- }, delay);
256
+ if (this.prop.classToToggle) {
257
+ timeoutCallback_1.default(function () {
258
+ el.classList.toggle(_this.prop.classToToggle, inViewport);
259
+ }, delay);
260
+ }
279
261
  // process callbacks
280
262
  if (inViewport && (states === 'in' || states === 'inout')) {
281
263
  timeoutCallback_1.default(function () {
@@ -305,6 +287,36 @@ var ScrollView = /** @class */ (function (_super) {
305
287
  });
306
288
  this._elements = this._elements.filter(function (el) { return !el.scrollViewIn; });
307
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
+ };
308
320
  /**
309
321
  * Destroy the module
310
322
  */
@@ -156,8 +156,11 @@ var Bar = /** @class */ (function () {
156
156
  this._listeners.push(vevet_dom_1.addEventListener(this.outer, 'mouseenter', this._handleHover.bind(this, true)));
157
157
  this._listeners.push(vevet_dom_1.addEventListener(this.outer, 'mouseleave', this._handleHover.bind(this, false)));
158
158
  // set scroll events
159
- this._scrollEvent = onScroll_1.default(this.prop.container, function (data) {
160
- _this._handleScroll(data);
159
+ this._scrollEvent = onScroll_1.default({
160
+ container: this.prop.container,
161
+ callback: function (data) {
162
+ _this._handleScroll(data);
163
+ },
161
164
  });
162
165
  // set dragger
163
166
  if (this.prop.isDraggable) {
@@ -87,9 +87,11 @@ var SmoothScroll = /** @class */ (function (_super) {
87
87
  }
88
88
  _this._elementsLength = _this._elements.length;
89
89
  // add will-change
90
- _this._elements.forEach(function (el) {
91
- el.style.willChange = 'transform';
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();
@@ -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
  }
@@ -2,49 +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(selector, callback, props) {
9
- var listeners = [];
10
- var smoothScrollEvent;
11
- if (selector instanceof SmoothScroll_1.SmoothScroll) {
12
- smoothScrollEvent = selector.addCallback('scroll', function () {
13
- callback({
14
- scrollTop: selector.scrollTop,
15
- scrollLeft: selector.scrollLeft,
16
- });
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 = 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,
17
20
  });
18
21
  }
19
22
  else {
20
- var outer_1;
21
- if (typeof selector === 'string') {
22
- outer_1 = vevet_dom_1.selectOne(selector);
23
+ // otherwise we create a new instance
24
+ instance = {
25
+ id: 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
+ }));
23
48
  }
24
49
  else {
25
- outer_1 = selector;
26
- }
27
- if (outer_1) {
28
- listeners.push(vevet_dom_1.addEventListener(outer_1, 'scroll', function () {
29
- var scrollTop = outer_1 instanceof Window
30
- ? outer_1.pageYOffset : outer_1.scrollTop;
31
- var scrollLeft = outer_1 instanceof Window
32
- ? outer_1.pageXOffset : outer_1.scrollLeft;
33
- callback({
34
- scrollTop: scrollTop,
35
- scrollLeft: scrollLeft,
36
- });
37
- }, props ? {
38
- passive: props.passive,
39
- } : undefined));
50
+ // dom scroll events
51
+ var isWindow_1 = container instanceof Window;
52
+ var domContainer_1 = vevet_dom_1.selectOne(container);
53
+ listeners.push(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
+ }));
40
67
  }
41
68
  }
42
69
  return {
43
70
  remove: function () {
44
- listeners.forEach(function (listener) {
45
- listener.remove();
71
+ var newCallbacks = instance.callbacks.filter(function (item) {
72
+ if (item.id !== callbackId) {
73
+ return true;
74
+ }
75
+ return false;
46
76
  });
47
- smoothScrollEvent === null || smoothScrollEvent === void 0 ? void 0 : smoothScrollEvent.remove();
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
+ }
48
84
  },
49
85
  };
50
86
  }
@@ -1,4 +1,3 @@
1
- import { selectAll } from 'vevet-dom';
2
1
  import { ScrollEventsBase } from './ScrollEventsBase';
3
2
  import onScroll from '../../../utils/listeners/onScroll';
4
3
  import { intersectionObserverSupported } from '../../../utils/listeners';
@@ -13,8 +12,7 @@ export class ScrollView extends ScrollEventsBase {
13
12
  this._scrollEvent = undefined;
14
13
  this._intersectionObserver = undefined;
15
14
  this._firstStart = true;
16
- // get view elements
17
- this.updateElements();
15
+ this._elements = [...this.prop.elements];
18
16
  // initialize the class
19
17
  if (init) {
20
18
  this.init();
@@ -24,11 +22,16 @@ export class ScrollView extends ScrollEventsBase {
24
22
  return `${this._app.prefix}scroll-view`;
25
23
  }
26
24
  _getDefaultProp() {
27
- return Object.assign(Object.assign({}, super._getDefaultProp()), { container: window, elements: `.${this.prefix}__el`, threshold: 0.9, states: 'in', classToToggle: 'viewed', useDelay: false, useIntersectionObserver: true });
25
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { enabled: true, container: window, elements: [], threshold: 0.9, states: 'in', classToToggle: 'viewed', useDelay: false, useIntersectionObserver: true });
26
+ }
27
+ /**
28
+ * Elements to seek
29
+ */
30
+ get elements() {
31
+ return this._elements;
28
32
  }
29
33
  init() {
30
34
  super.init();
31
- this.seekBounding();
32
35
  }
33
36
  // Set Module Events
34
37
  _setEvents() {
@@ -40,16 +43,17 @@ export class ScrollView extends ScrollEventsBase {
40
43
  }
41
44
  _onPropMutate() {
42
45
  super._onPropMutate();
43
- this._removeViewEvents();
44
- this.updateElements();
45
- this._setViewEvents();
46
+ this.resize();
46
47
  }
47
48
  /**
48
49
  * Resize the scene
49
50
  */
50
51
  resize() {
51
52
  this._removeViewEvents();
52
- this._setViewEvents();
53
+ if (this.prop.enabled) {
54
+ this._setViewEvents();
55
+ this.seekBounding();
56
+ }
53
57
  }
54
58
  /**
55
59
  * Set View events: scroll or intersection
@@ -70,16 +74,17 @@ export class ScrollView extends ScrollEventsBase {
70
74
  rootMargin: `0px ${xMargin}px ${yMargin}px 0px`,
71
75
  });
72
76
  // add elements
73
- if (this.elements) {
74
- this.elements.forEach((el) => {
75
- var _a;
76
- (_a = this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
77
- });
78
- }
77
+ this.elements.forEach((el) => {
78
+ var _a;
79
+ (_a = this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
80
+ });
79
81
  }
80
82
  else {
81
83
  // set scroll bounding events
82
- this._scrollEvent = onScroll(this.prop.container, this._handleScroll.bind(this));
84
+ this._scrollEvent = onScroll({
85
+ container: this.prop.container,
86
+ callback: this._handleScroll.bind(this),
87
+ });
83
88
  }
84
89
  }
85
90
  /**
@@ -97,35 +102,6 @@ export class ScrollView extends ScrollEventsBase {
97
102
  this._intersectionObserver = undefined;
98
103
  }
99
104
  }
100
- /**
101
- * Element to seek
102
- */
103
- get elements() {
104
- return this._elements;
105
- }
106
- /**
107
- * Update elements
108
- */
109
- updateElements() {
110
- // check if elements exist
111
- if (typeof this.elements === 'undefined') {
112
- this._elements = [];
113
- }
114
- // unobserve old elements
115
- this.elements.forEach((el) => {
116
- if (this._intersectionObserver) {
117
- this._intersectionObserver.unobserve(el);
118
- }
119
- });
120
- // update elements
121
- this._elements = Array.from(selectAll(this.prop.elements, this.domParent || undefined)).filter((el) => !el.classList.contains(this.prop.classToToggle));
122
- // add them to the observer
123
- this._elements.forEach((el) => {
124
- if (this._intersectionObserver) {
125
- this._intersectionObserver.observe(el);
126
- }
127
- });
128
- }
129
105
  /**
130
106
  * Event on IntersectionObserver
131
107
  */
@@ -225,9 +201,11 @@ export class ScrollView extends ScrollEventsBase {
225
201
  // update props
226
202
  el.scrollViewIn = inViewport;
227
203
  // toggle classes
228
- timeoutCallback(() => {
229
- el.classList.toggle(this.prop.classToToggle, inViewport);
230
- }, delay);
204
+ if (this.prop.classToToggle) {
205
+ timeoutCallback(() => {
206
+ el.classList.toggle(this.prop.classToToggle, inViewport);
207
+ }, delay);
208
+ }
231
209
  // process callbacks
232
210
  if (inViewport && (states === 'in' || states === 'inout')) {
233
211
  timeoutCallback(() => {
@@ -256,6 +234,35 @@ export class ScrollView extends ScrollEventsBase {
256
234
  });
257
235
  this._elements = this._elements.filter((el) => !el.scrollViewIn);
258
236
  }
237
+ /**
238
+ * Add a view element
239
+ */
240
+ addElement(element) {
241
+ this._elements.push(element);
242
+ if (this._intersectionObserver) {
243
+ this._intersectionObserver.observe(element);
244
+ }
245
+ }
246
+ /**
247
+ * Remove a view element
248
+ */
249
+ removeElement(element) {
250
+ this._elements = this._elements.filter((el) => el !== element);
251
+ if (this._intersectionObserver) {
252
+ this._intersectionObserver.unobserve(element);
253
+ }
254
+ }
255
+ /**
256
+ * Remove all view elements
257
+ */
258
+ removeElements() {
259
+ this._elements.forEach((el) => {
260
+ if (this._intersectionObserver) {
261
+ this._intersectionObserver.unobserve(el);
262
+ }
263
+ });
264
+ this._elements = [];
265
+ }
259
266
  /**
260
267
  * Destroy the module
261
268
  */
@@ -106,8 +106,11 @@ export default class Bar {
106
106
  this._listeners.push(addEventListener(this.outer, 'mouseenter', this._handleHover.bind(this, true)));
107
107
  this._listeners.push(addEventListener(this.outer, 'mouseleave', this._handleHover.bind(this, false)));
108
108
  // set scroll events
109
- this._scrollEvent = onScroll(this.prop.container, (data) => {
110
- this._handleScroll(data);
109
+ this._scrollEvent = onScroll({
110
+ container: this.prop.container,
111
+ callback: (data) => {
112
+ this._handleScroll(data);
113
+ },
111
114
  });
112
115
  // set dragger
113
116
  if (this.prop.isDraggable) {
@@ -53,9 +53,11 @@ export class SmoothScroll extends Component {
53
53
  }
54
54
  this._elementsLength = this._elements.length;
55
55
  // add will-change
56
- this._elements.forEach((el) => {
57
- el.style.willChange = 'transform';
58
- });
56
+ if (this.prop.useWillChange) {
57
+ this._elements.forEach((el) => {
58
+ el.style.willChange = 'transform';
59
+ });
60
+ }
59
61
  // initialize the class
60
62
  if (init) {
61
63
  this.init();
@@ -32,7 +32,7 @@ export class SplitText extends Component {
32
32
  }
33
33
  }
34
34
  _getDefaultProp() {
35
- return Object.assign(Object.assign({}, super._getDefaultProp()), { container: `#${this.prefix}`, appendLetters: true, appendLines: false });
35
+ return Object.assign(Object.assign({}, super._getDefaultProp()), { container: `#${this.prefix}`, appendLetters: true, appendLines: false, viewportTarget: '' });
36
36
  }
37
37
  get prefix() {
38
38
  return `${this._app.prefix}split-text`;
@@ -57,7 +57,7 @@ export class SplitText extends Component {
57
57
  // split the text
58
58
  this.splitText();
59
59
  if (this.prop.appendLines) {
60
- this.addViewportCallback('', () => {
60
+ this.addViewportCallback(this.prop.viewportTarget, () => {
61
61
  this.splitText();
62
62
  });
63
63
  }