vscroll 1.4.3 → 1.4.4

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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +17 -16
  3. package/dist/bundles/vscroll.esm5.js +107 -103
  4. package/dist/bundles/vscroll.esm5.js.map +1 -1
  5. package/dist/bundles/vscroll.esm5.min.js +2 -2
  6. package/dist/bundles/vscroll.esm5.min.js.map +1 -1
  7. package/dist/bundles/vscroll.esm6.js +104 -103
  8. package/dist/bundles/vscroll.esm6.js.map +1 -1
  9. package/dist/bundles/vscroll.esm6.min.js +2 -2
  10. package/dist/bundles/vscroll.esm6.min.js.map +1 -1
  11. package/dist/bundles/vscroll.umd.js +108 -104
  12. package/dist/bundles/vscroll.umd.js.map +1 -1
  13. package/dist/bundles/vscroll.umd.min.js +2 -2
  14. package/dist/bundles/vscroll.umd.min.js.map +1 -1
  15. package/dist/esm2015/classes/domRoutines.js +82 -69
  16. package/dist/esm2015/classes/domRoutines.js.map +1 -1
  17. package/dist/esm2015/classes/logger.js +2 -2
  18. package/dist/esm2015/classes/logger.js.map +1 -1
  19. package/dist/esm2015/classes/paddings.js +5 -5
  20. package/dist/esm2015/classes/paddings.js.map +1 -1
  21. package/dist/esm2015/classes/viewport.js +9 -21
  22. package/dist/esm2015/classes/viewport.js.map +1 -1
  23. package/dist/esm2015/interfaces/index.js.map +1 -1
  24. package/dist/esm2015/interfaces/routines.js +2 -0
  25. package/dist/esm2015/interfaces/routines.js.map +1 -0
  26. package/dist/esm2015/scroller.js +3 -3
  27. package/dist/esm2015/scroller.js.map +1 -1
  28. package/dist/esm2015/version.js +1 -1
  29. package/dist/esm2015/version.js.map +1 -1
  30. package/dist/esm2015/workflow.js +2 -2
  31. package/dist/esm2015/workflow.js.map +1 -1
  32. package/dist/esm5/classes/domRoutines.js +85 -69
  33. package/dist/esm5/classes/domRoutines.js.map +1 -1
  34. package/dist/esm5/classes/logger.js +2 -2
  35. package/dist/esm5/classes/logger.js.map +1 -1
  36. package/dist/esm5/classes/paddings.js +5 -5
  37. package/dist/esm5/classes/paddings.js.map +1 -1
  38. package/dist/esm5/classes/viewport.js +9 -21
  39. package/dist/esm5/classes/viewport.js.map +1 -1
  40. package/dist/esm5/interfaces/index.js.map +1 -1
  41. package/dist/esm5/interfaces/routines.js +2 -0
  42. package/dist/esm5/interfaces/routines.js.map +1 -0
  43. package/dist/esm5/scroller.js +3 -3
  44. package/dist/esm5/scroller.js.map +1 -1
  45. package/dist/esm5/version.js +1 -1
  46. package/dist/esm5/version.js.map +1 -1
  47. package/dist/esm5/workflow.js +2 -2
  48. package/dist/esm5/workflow.js.map +1 -1
  49. package/dist/typings/classes/domRoutines.d.ts +21 -19
  50. package/dist/typings/classes/logger.d.ts +1 -1
  51. package/dist/typings/classes/paddings.d.ts +2 -2
  52. package/dist/typings/classes/viewport.d.ts +1 -4
  53. package/dist/typings/interfaces/index.d.ts +2 -1
  54. package/dist/typings/interfaces/routines.d.ts +154 -0
  55. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Denis Hilt (https://github.com/dhilt)
3
+ Copyright (c) 2022 Denis Hilt (https://github.com/dhilt)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -140,17 +140,18 @@ This obliges the Datasource.get method to deal with _Data_ items and also provid
140
140
  A callback that is called every time the Workflow decides that the UI needs to be changed. Its argument is a list of items to be present in the UI. This is a consumer responsibility to detect changes and display them in the UI.
141
141
 
142
142
  ```js
143
- run: items => {
144
- // assume currentItems contains a list of items currently presented in the UI
145
- if (!items.length && !currentItems.length) {
143
+ run: (newItems) => {
144
+ // assume oldItems contains a list of items that are currently present in the UI
145
+ if (!newItems.length && !oldItems.length) {
146
146
  return;
147
147
  }
148
- displayNewItemsInsteadCurrentOnes(items, currentItems);
149
- currentItems = items;
150
- }
148
+ // make newItems to be present in the UI instead of oldItems
149
+ processItems(newItems, oldItems);
150
+ oldItems = newItems;
151
+ };
151
152
  ```
152
153
 
153
- Each item is an instance of the [Item class](https://github.com/dhilt/vscroll/blob/v1.0.0/src/classes/item.ts) implementing the [Item interface](https://github.com/dhilt/vscroll/blob/v1.0.0/src/interfaces/item.ts), whose props can be used for proper implementation of the `run` callback:
154
+ Each item (in both `newItems` and `oldItems` lists) is an instance of the [Item class](https://github.com/dhilt/vscroll/blob/v1.0.0/src/classes/item.ts) implementing the [Item interface](https://github.com/dhilt/vscroll/blob/v1.0.0/src/interfaces/item.ts), whose props can be used for proper implementation of the `run` callback:
154
155
 
155
156
  |Name|Type|Description|
156
157
  |:--|:--|:----|
@@ -162,19 +163,19 @@ Each item is an instance of the [Item class](https://github.com/dhilt/vscroll/bl
162
163
 
163
164
  `Run` callback is the most complex and environment-specific part of the `vscroll` API, which is fully depends on the environment for which the consumer is being created. Framework specific consumer should rely on internal mechanism of the framework to provide runtime DOM modifications.
164
165
 
165
- There are some requirements on how the `items` should be processed by `run(items)` call:
166
- - after the `run(items)` callback is completed, there must be `items.length` elements in the DOM between backward and forward padding elements;
167
- - old items that are not in the list should be removed from DOM; use `currentItems[].element` reference for this purpose;
168
- - old items that are in the list should not be removed and recreated, as it may lead to an unwanted shift of the scroll position; just don't touch them;
169
- - new items elements should be rendered in accordance with `items[].$index` comparable to `$index` of elements that remain: `$index` must increase continuously and the directions of increase must persist across the `run` calls; Scroller maintains `$index` internally, so you only need to properly inject the `items[].element` into the DOM;
170
- - new elements should be rendered but not visible, and this should be achieved by "fixed" positioning and "left"/"top" coordinates placing the item element out of view; the Workflow will take care of visibility after calculations; an additional attribute `items[].invisible` can be used to determine if a given element should be hidden;
171
- - new items elements should have "data-sid" attribute, which value should reflect `items[].$index`;
166
+ There are some requirements on how the items should be processed by `run` call:
167
+ - after the `run` callback is completed, there must be `newItems.length` elements in the DOM between backward and forward padding elements;
168
+ - old items that are not in the new item list should be removed from DOM; use `oldItems[].element` references for this purpose;
169
+ - old items that are in the list should not be removed and recreated, as it may lead to an unwanted shift of the scroll position; just don't touch them;
170
+ - new items elements should be rendered in accordance with `newItems[].$index` comparable to `$index` of elements that remain: `$index` must increase continuously and the directions of increase must persist across the `run` calls; Scroller maintains `$index` internally, so you only need to properly inject a set of `newItems[].element` into the DOM;
171
+ - new elements should be rendered but not visible, and this should be achieved by "fixed" positioning and "left"/"top" coordinates placing the item element out of view; the Workflow will take care of visibility after calculations; an additional attribute `newItems[].invisible` can be used to determine if a given element should be hidden;
172
+ - new items elements should have "data-sid" attribute, which value should reflect `newItems[].$index`;
172
173
 
173
174
  ## Live
174
175
 
175
176
  This repository has a minimal demonstration of the App-consumer implementation considering all of the requirements listed above: https://dhilt.github.io/vscroll/. This is all-in-one HTML demo with `vscroll` taken from CDN. The source code of the demo is [here](https://github.com/dhilt/vscroll/blob/main/demo/index.html). The approach is rough and non-optimized, if you are seeking for more general solution for native JavaScript applications, please take a look at [vscroll-native](https://github.com/dhilt/vscroll-native) project. It is relatively new and has no good documentation, but its [source code](https://github.com/dhilt/vscroll-native/tree/main/src) and [demo](https://github.com/dhilt/vscroll-native/tree/main/demo) may shed light on `vscroll` usage in no-framework environment.
176
177
 
177
- Another example is [ngx-ui-scroll](https://github.com/dhilt/ngx-ui-scroll). Before 2021 `vscroll` was part of `ngx-ui-scroll`, and its [demo page](https://dhilt.github.io/ngx-ui-scroll/#/) contains well-documented samples that can be used to get an idea on the API and functionality offered by `vscroll`. The code of the [UiScrollComponent](https://github.com/dhilt/ngx-ui-scroll/blob/v2.0.0-rc.1/src/ui-scroll.component.ts) clearly demonstrates the `Workflow` instantiation in the context of Angular. Also, since ngx-ui-scroll is the intermediate layer between `vscroll` and the end Application, the Datasource is being provided from the outside. Method `makeDatasource` is used to provide `Datasource` class to the end Application.
178
+ Another example is [ngx-ui-scroll](https://github.com/dhilt/ngx-ui-scroll). Before 2021 `vscroll` was part of `ngx-ui-scroll`, and its [demo page](https://dhilt.github.io/ngx-ui-scroll/#/) contains well-documented samples that can be used to get an idea on the API and functionality offered by `vscroll`. The code of the [UiScrollComponent](https://github.com/dhilt/ngx-ui-scroll/blob/v2.2.0/src/ui-scroll.component.ts) clearly demonstrates the `Workflow` instantiation in the context of Angular. Also, since ngx-ui-scroll is the intermediate layer between `vscroll` and the end Application, the Datasource is being provided from the outside. Method `makeDatasource` is used to provide `Datasource` class to the end Application.
178
179
 
179
180
  ## Adapter API
180
181
 
@@ -223,4 +224,4 @@ VScroll will receive its own Adapter API documentation later, but for now please
223
224
 
224
225
  __________
225
226
 
226
- 2021 © [Denis Hilt](https://github.com/dhilt)
227
+ 2022 © [Denis Hilt](https://github.com/dhilt)
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * vscroll (https://github.com/dhilt/vscroll) FESM5
3
- * Version: 1.4.3 (2021-11-30T02:54:00.541Z)
3
+ * Version: 1.4.4 (2022-01-22T00:43:17.423Z)
4
4
  * Author: Denis Hilt
5
5
  * License: MIT
6
6
  */
@@ -343,7 +343,7 @@ var reactiveConfigStorage = new Map();
343
343
 
344
344
  var core = {
345
345
  name: 'vscroll',
346
- version: '1.4.3'
346
+ version: '1.4.4'
347
347
  };
348
348
 
349
349
  var instanceCount$1 = 0;
@@ -2983,7 +2983,7 @@ var Logger = /** @class */ (function () {
2983
2983
  this.getWorkflowCycleData = function () {
2984
2984
  return settings.instanceIndex + "-" + scroller.state.cycle.count;
2985
2985
  };
2986
- this.getScrollPosition = function (element) { return scroller.routines.getScrollPosition(element); };
2986
+ this.getScrollPosition = function () { return scroller.routines.getScrollPosition(); };
2987
2987
  this.log(function () {
2988
2988
  return 'vscroll Workflow has been started, ' +
2989
2989
  ("core: " + packageInfo.core.name + " v" + packageInfo.core.version + ", ") +
@@ -3043,7 +3043,7 @@ var Logger = /** @class */ (function () {
3043
3043
  };
3044
3044
  Logger.prototype.prepareForLog = function (data) {
3045
3045
  return data instanceof Event && data.target
3046
- ? this.getScrollPosition(data.target)
3046
+ ? this.getScrollPosition()
3047
3047
  : data;
3048
3048
  };
3049
3049
  Logger.prototype.logProcess = function (data) {
@@ -3138,64 +3138,63 @@ var Logger = /** @class */ (function () {
3138
3138
  }());
3139
3139
 
3140
3140
  var Routines = /** @class */ (function () {
3141
- function Routines(settings) {
3142
- this.horizontal = settings.horizontal;
3143
- this.window = settings.windowViewport;
3144
- this.viewport = settings.viewport;
3141
+ function Routines(element, settings) {
3142
+ this.settings = {
3143
+ viewport: settings.viewport,
3144
+ horizontal: settings.horizontal,
3145
+ window: settings.windowViewport
3146
+ };
3147
+ this.element = element;
3148
+ this.viewport = this.getViewportElement();
3149
+ this.onInit(settings);
3145
3150
  }
3146
3151
  Routines.prototype.checkElement = function (element) {
3147
3152
  if (!element) {
3148
3153
  throw new Error('HTML element is not defined');
3149
3154
  }
3150
3155
  };
3151
- Routines.prototype.getHostElement = function (element) {
3152
- if (this.window) {
3156
+ Routines.prototype.getViewportElement = function () {
3157
+ if (this.settings.window) {
3153
3158
  return document.documentElement;
3154
3159
  }
3155
- if (this.viewport) {
3156
- return this.viewport;
3160
+ if (this.settings.viewport) {
3161
+ return this.settings.viewport;
3157
3162
  }
3158
- this.checkElement(element);
3159
- var parent = element.parentElement;
3163
+ this.checkElement(this.element);
3164
+ var parent = this.element.parentElement;
3160
3165
  this.checkElement(parent);
3161
3166
  return parent;
3162
3167
  };
3163
- Routines.prototype.getScrollEventReceiver = function (element) {
3164
- if (this.window) {
3165
- return window;
3168
+ Routines.prototype.onInit = function (settings) {
3169
+ if (settings.windowViewport) {
3170
+ if ('scrollRestoration' in history) {
3171
+ history.scrollRestoration = 'manual';
3172
+ }
3166
3173
  }
3167
- return this.getHostElement(element);
3168
- };
3169
- Routines.prototype.setupScrollRestoration = function () {
3170
- if ('scrollRestoration' in history) {
3171
- history.scrollRestoration = 'manual';
3174
+ if (settings.dismissOverflowAnchor) {
3175
+ this.viewport.style.overflowAnchor = 'none';
3172
3176
  }
3173
3177
  };
3174
- Routines.prototype.dismissOverflowAnchor = function (element) {
3175
- this.checkElement(element);
3176
- element.style.overflowAnchor = 'none';
3177
- };
3178
3178
  Routines.prototype.findElementBySelector = function (element, selector) {
3179
3179
  this.checkElement(element);
3180
3180
  return element.querySelector(selector);
3181
3181
  };
3182
- Routines.prototype.findPaddingElement = function (element, direction) {
3183
- return this.findElementBySelector(element, "[data-padding-" + direction + "]");
3182
+ Routines.prototype.findPaddingElement = function (direction) {
3183
+ return this.findElementBySelector(this.element, "[data-padding-" + direction + "]");
3184
3184
  };
3185
- Routines.prototype.findItemElement = function (element, id) {
3186
- return this.findElementBySelector(element, "[data-sid=\"" + id + "\"]");
3185
+ Routines.prototype.findItemElement = function (id) {
3186
+ return this.findElementBySelector(this.element, "[data-sid=\"" + id + "\"]");
3187
3187
  };
3188
- Routines.prototype.getScrollPosition = function (element) {
3189
- if (this.window) {
3190
- return window.pageYOffset;
3188
+ Routines.prototype.getScrollPosition = function () {
3189
+ if (this.settings.window) {
3190
+ return this.settings.horizontal ? window.pageXOffset : window.pageYOffset;
3191
3191
  }
3192
- this.checkElement(element);
3193
- return element[this.horizontal ? 'scrollLeft' : 'scrollTop'];
3192
+ return this.viewport[this.settings.horizontal ? 'scrollLeft' : 'scrollTop'];
3194
3193
  };
3195
- Routines.prototype.setScrollPosition = function (element, value) {
3194
+ Routines.prototype.setScrollPosition = function (value) {
3196
3195
  value = Math.max(0, value);
3197
- if (this.window) {
3198
- if (this.horizontal) {
3196
+ if (this.settings.window) {
3197
+ if (this.settings.horizontal) {
3199
3198
  window.scrollTo(value, window.scrollY);
3200
3199
  }
3201
3200
  else {
@@ -3203,49 +3202,62 @@ var Routines = /** @class */ (function () {
3203
3202
  }
3204
3203
  return;
3205
3204
  }
3206
- this.checkElement(element);
3207
- element[this.horizontal ? 'scrollLeft' : 'scrollTop'] = value;
3205
+ this.viewport[this.settings.horizontal ? 'scrollLeft' : 'scrollTop'] = value;
3208
3206
  };
3209
- Routines.prototype.getParams = function (element, doNotBind) {
3207
+ Routines.prototype.getElementParams = function (element) {
3210
3208
  this.checkElement(element);
3211
- if (this.window && doNotBind) {
3212
- var clientWidth = element.clientWidth, clientHeight = element.clientHeight, clientLeft = element.clientLeft, clientTop = element.clientTop;
3213
- return {
3214
- 'height': clientHeight,
3215
- 'width': clientWidth,
3216
- 'top': clientTop,
3217
- 'bottom': clientTop + clientHeight,
3218
- 'left': clientLeft,
3219
- 'right': clientLeft + clientWidth,
3220
- 'x': clientLeft,
3221
- 'y': clientTop,
3222
- 'toJSON': function () { return null; },
3223
- };
3224
- }
3225
3209
  return element.getBoundingClientRect();
3226
3210
  };
3227
- Routines.prototype.getSize = function (element, doNotBind) {
3228
- return this.getParams(element, doNotBind)[this.horizontal ? 'width' : 'height'];
3211
+ Routines.prototype.getWindowParams = function () {
3212
+ var _a = this.viewport, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight, clientLeft = _a.clientLeft, clientTop = _a.clientTop;
3213
+ return {
3214
+ 'height': clientHeight,
3215
+ 'width': clientWidth,
3216
+ 'top': clientTop,
3217
+ 'bottom': clientTop + clientHeight,
3218
+ 'left': clientLeft,
3219
+ 'right': clientLeft + clientWidth,
3220
+ 'x': clientLeft,
3221
+ 'y': clientTop,
3222
+ 'toJSON': function () { return null; },
3223
+ };
3224
+ };
3225
+ Routines.prototype.getSize = function (element) {
3226
+ return this.getElementParams(element)[this.settings.horizontal ? 'width' : 'height'];
3227
+ };
3228
+ Routines.prototype.getScrollerSize = function () {
3229
+ return this.getElementParams(this.element)[this.settings.horizontal ? 'width' : 'height'];
3230
+ };
3231
+ Routines.prototype.getViewportSize = function () {
3232
+ if (this.settings.window) {
3233
+ return this.getWindowParams()[this.settings.horizontal ? 'width' : 'height'];
3234
+ }
3235
+ return this.getSize(this.viewport);
3229
3236
  };
3230
3237
  Routines.prototype.getSizeStyle = function (element) {
3231
3238
  this.checkElement(element);
3232
- var size = element.style[this.horizontal ? 'width' : 'height'];
3239
+ var size = element.style[this.settings.horizontal ? 'width' : 'height'];
3233
3240
  return parseFloat(size) || 0;
3234
3241
  };
3235
3242
  Routines.prototype.setSizeStyle = function (element, value) {
3236
3243
  this.checkElement(element);
3237
3244
  value = Math.max(0, Math.round(value));
3238
- element.style[this.horizontal ? 'width' : 'height'] = value + "px";
3245
+ element.style[this.settings.horizontal ? 'width' : 'height'] = value + "px";
3239
3246
  };
3240
- Routines.prototype.getEdge = function (element, direction, doNotBind) {
3241
- var params = this.getParams(element, doNotBind);
3247
+ Routines.prototype.getEdge = function (element, direction) {
3248
+ var horizontal = this.settings.horizontal;
3249
+ var params = this.getElementParams(element);
3242
3250
  var isFwd = direction === Direction.forward;
3243
- return params[isFwd ? (this.horizontal ? 'right' : 'bottom') : (this.horizontal ? 'left' : 'top')];
3251
+ return params[isFwd ? (horizontal ? 'right' : 'bottom') : (horizontal ? 'left' : 'top')];
3244
3252
  };
3245
- Routines.prototype.getEdge2 = function (element, direction, relativeElement, opposite) {
3246
- // vertical only ?
3247
- return element.offsetTop - (relativeElement ? relativeElement.scrollTop : 0) +
3248
- (direction === (!opposite ? Direction.forward : Direction.backward) ? this.getSize(element) : 0);
3253
+ Routines.prototype.getViewportEdge = function (direction) {
3254
+ var _a = this.settings, window = _a.window, horizontal = _a.horizontal;
3255
+ if (window) {
3256
+ var params = this.getWindowParams();
3257
+ var isFwd = direction === Direction.forward;
3258
+ return params[isFwd ? (horizontal ? 'right' : 'bottom') : (horizontal ? 'left' : 'top')];
3259
+ }
3260
+ return this.getEdge(this.viewport, direction);
3249
3261
  };
3250
3262
  Routines.prototype.makeElementVisible = function (element) {
3251
3263
  this.checkElement(element);
@@ -3257,9 +3269,12 @@ var Routines = /** @class */ (function () {
3257
3269
  this.checkElement(element);
3258
3270
  element.style.display = 'none';
3259
3271
  };
3260
- Routines.prototype.getOffset = function (element) {
3261
- this.checkElement(element);
3262
- return (this.horizontal ? element.offsetLeft : element.offsetTop) || 0;
3272
+ Routines.prototype.getOffset = function () {
3273
+ var _this = this;
3274
+ var get = function (element) {
3275
+ return (_this.settings.horizontal ? element.offsetLeft : element.offsetTop) || 0;
3276
+ };
3277
+ return get(this.element) - (!this.settings.window ? get(this.viewport) : 0);
3263
3278
  };
3264
3279
  Routines.prototype.scrollTo = function (element, argument) {
3265
3280
  this.checkElement(element);
@@ -3273,16 +3288,17 @@ var Routines = /** @class */ (function () {
3273
3288
  var animationFrameId = requestAnimationFrame(function () { return cb(); });
3274
3289
  return function () { return cancelAnimationFrame(animationFrameId); };
3275
3290
  };
3276
- Routines.prototype.onScroll = function (element, handler) {
3277
- element.addEventListener('scroll', handler);
3278
- return function () { return element.removeEventListener('scroll', handler); };
3291
+ Routines.prototype.onScroll = function (handler) {
3292
+ var eventReceiver = this.settings.window ? window : this.viewport;
3293
+ eventReceiver.addEventListener('scroll', handler);
3294
+ return function () { return eventReceiver.removeEventListener('scroll', handler); };
3279
3295
  };
3280
3296
  return Routines;
3281
3297
  }());
3282
3298
 
3283
3299
  var Padding = /** @class */ (function () {
3284
- function Padding(element, direction, routines) {
3285
- var found = routines.findPaddingElement(element, direction);
3300
+ function Padding(direction, routines) {
3301
+ var found = routines.findPaddingElement(direction);
3286
3302
  routines.checkElement(found);
3287
3303
  this.element = found;
3288
3304
  this.direction = direction;
@@ -3304,10 +3320,10 @@ var Padding = /** @class */ (function () {
3304
3320
  return Padding;
3305
3321
  }());
3306
3322
  var Paddings = /** @class */ (function () {
3307
- function Paddings(element, routines, settings) {
3323
+ function Paddings(routines, settings) {
3308
3324
  this.settings = settings;
3309
- this.forward = new Padding(element, Direction.forward, routines);
3310
- this.backward = new Padding(element, Direction.backward, routines);
3325
+ this.forward = new Padding(Direction.forward, routines);
3326
+ this.backward = new Padding(Direction.backward, routines);
3311
3327
  }
3312
3328
  Paddings.prototype.byDirection = function (direction, opposite) {
3313
3329
  return direction === Direction.backward
@@ -3359,21 +3375,12 @@ var Paddings = /** @class */ (function () {
3359
3375
  }());
3360
3376
 
3361
3377
  var Viewport = /** @class */ (function () {
3362
- function Viewport(element, settings, routines, state, logger) {
3363
- this.element = element;
3378
+ function Viewport(settings, routines, state, logger) {
3364
3379
  this.settings = settings;
3365
3380
  this.routines = routines;
3366
3381
  this.state = state;
3367
3382
  this.logger = logger;
3368
- this.hostElement = this.routines.getHostElement(this.element);
3369
- this.scrollEventReceiver = this.routines.getScrollEventReceiver(this.element);
3370
- if (settings.windowViewport) {
3371
- this.routines.setupScrollRestoration();
3372
- }
3373
- if (settings.dismissOverflowAnchor) {
3374
- this.routines.dismissOverflowAnchor(this.hostElement);
3375
- }
3376
- this.paddings = new Paddings(this.element, this.routines, settings);
3383
+ this.paddings = new Paddings(this.routines, settings);
3377
3384
  }
3378
3385
  Viewport.prototype.reset = function (startIndex) {
3379
3386
  this.setOffset();
@@ -3387,7 +3394,7 @@ var Viewport = /** @class */ (function () {
3387
3394
  this.logger.log(function () { return ['setting scroll position at', value, '[cancelled]']; });
3388
3395
  return value;
3389
3396
  }
3390
- this.routines.setScrollPosition(this.hostElement, value);
3397
+ this.routines.setScrollPosition(value);
3391
3398
  var position = this.scrollPosition;
3392
3399
  this.logger.log(function () { return __spreadArray([
3393
3400
  'setting scroll position at', position
@@ -3396,7 +3403,7 @@ var Viewport = /** @class */ (function () {
3396
3403
  };
3397
3404
  Object.defineProperty(Viewport.prototype, "scrollPosition", {
3398
3405
  get: function () {
3399
- return this.routines.getScrollPosition(this.hostElement);
3406
+ return this.routines.getScrollPosition();
3400
3407
  },
3401
3408
  set: function (value) {
3402
3409
  this.setPosition(value);
@@ -3405,10 +3412,10 @@ var Viewport = /** @class */ (function () {
3405
3412
  configurable: true
3406
3413
  });
3407
3414
  Viewport.prototype.getSize = function () {
3408
- return this.routines.getSize(this.hostElement, true);
3415
+ return this.routines.getViewportSize();
3409
3416
  };
3410
3417
  Viewport.prototype.getScrollableSize = function () {
3411
- return this.routines.getSize(this.element);
3418
+ return this.routines.getScrollerSize();
3412
3419
  };
3413
3420
  Viewport.prototype.getMaxScrollPosition = function () {
3414
3421
  return this.getScrollableSize() - this.getSize();
@@ -3417,16 +3424,13 @@ var Viewport = /** @class */ (function () {
3417
3424
  return this.getSize() * this.settings.padding;
3418
3425
  };
3419
3426
  Viewport.prototype.getEdge = function (direction) {
3420
- return this.routines.getEdge(this.hostElement, direction, true);
3427
+ return this.routines.getViewportEdge(direction);
3421
3428
  };
3422
3429
  Viewport.prototype.setOffset = function () {
3423
- this.offset = this.routines.getOffset(this.element);
3424
- if (!this.settings.windowViewport) {
3425
- this.offset -= this.routines.getOffset(this.hostElement);
3426
- }
3430
+ this.offset = this.routines.getOffset();
3427
3431
  };
3428
3432
  Viewport.prototype.findItemElementById = function (id) {
3429
- return this.routines.findItemElement(this.element, id);
3433
+ return this.routines.findItemElement(id);
3430
3434
  };
3431
3435
  Viewport.prototype.getEdgeVisibleItem = function (items, direction) {
3432
3436
  var bwd = direction === Direction.backward;
@@ -5124,15 +5128,15 @@ var Scroller = /** @class */ (function () {
5124
5128
  throw new Error(INVALID_DATASOURCE_PREFIX + " " + get.errors[0]);
5125
5129
  }
5126
5130
  var packageInfo = scroller ? scroller.state.packageInfo : { consumer: consumer, core: core };
5127
- element = scroller ? scroller.viewport.element : element;
5131
+ element = scroller ? scroller.routines.element : element;
5128
5132
  workflow = scroller ? scroller.workflow : workflow;
5129
5133
  this.workflow = workflow;
5130
5134
  this.settings = new Settings(datasource.settings, datasource.devSettings, ++instanceCount);
5131
5135
  this.logger = new Logger(this, packageInfo, datasource.adapter);
5132
- this.routines = new Routines(this.settings);
5136
+ this.routines = new Routines(element, this.settings);
5133
5137
  this.state = new State(packageInfo, this.settings, scroller ? scroller.state : void 0);
5134
5138
  this.buffer = new Buffer(this.settings, workflow.onDataChanged, this.logger);
5135
- this.viewport = new Viewport(element, this.settings, this.routines, this.state, this.logger);
5139
+ this.viewport = new Viewport(this.settings, this.routines, this.state, this.logger);
5136
5140
  this.logger.object('vscroll settings object', this.settings, true);
5137
5141
  this.initDatasource(datasource, scroller);
5138
5142
  }
@@ -5427,13 +5431,13 @@ var Workflow = /** @class */ (function () {
5427
5431
  status: ProcessStatus.start
5428
5432
  });
5429
5433
  // set up scroll event listener
5430
- var _a = this.scroller, scrollEventReceiver = _a.viewport.scrollEventReceiver, routines = _a.routines;
5434
+ var routines = this.scroller.routines;
5431
5435
  var onScrollHandler = function (event) { return _this.callWorkflow({
5432
5436
  process: CommonProcess.scroll,
5433
5437
  status: ProcessStatus.start,
5434
5438
  payload: { event: event }
5435
5439
  }); };
5436
- this.offScroll = routines.onScroll(scrollEventReceiver, onScrollHandler);
5440
+ this.offScroll = routines.onScroll(onScrollHandler);
5437
5441
  };
5438
5442
  Workflow.prototype.changeItems = function (items) {
5439
5443
  this.propagateChanges(items);