vscroll 1.4.3 → 1.5.1

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 (93) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +105 -58
  3. package/dist/bundles/vscroll.esm5.js +204 -176
  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 +122 -112
  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 +205 -177
  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/buffer.js +2 -6
  16. package/dist/esm2015/classes/buffer.js.map +1 -1
  17. package/dist/esm2015/classes/domRoutines.js +93 -69
  18. package/dist/esm2015/classes/domRoutines.js.map +1 -1
  19. package/dist/esm2015/classes/logger.js +2 -2
  20. package/dist/esm2015/classes/logger.js.map +1 -1
  21. package/dist/esm2015/classes/paddings.js +5 -5
  22. package/dist/esm2015/classes/paddings.js.map +1 -1
  23. package/dist/esm2015/classes/viewport.js +9 -21
  24. package/dist/esm2015/classes/viewport.js.map +1 -1
  25. package/dist/esm2015/index.js.map +1 -1
  26. package/dist/esm2015/interfaces/index.js.map +1 -1
  27. package/dist/esm2015/interfaces/routines.js +2 -0
  28. package/dist/esm2015/interfaces/routines.js.map +1 -0
  29. package/dist/esm2015/interfaces/workflow.js.map +1 -1
  30. package/dist/esm2015/scroller.js +4 -4
  31. package/dist/esm2015/scroller.js.map +1 -1
  32. package/dist/esm2015/version.js +1 -1
  33. package/dist/esm2015/version.js.map +1 -1
  34. package/dist/esm2015/workflow.js +6 -4
  35. package/dist/esm2015/workflow.js.map +1 -1
  36. package/dist/esm5/classes/adapter.js +4 -4
  37. package/dist/esm5/classes/adapter.js.map +1 -1
  38. package/dist/esm5/classes/buffer/cache.js +1 -1
  39. package/dist/esm5/classes/buffer/cache.js.map +1 -1
  40. package/dist/esm5/classes/buffer/checkCall.js +4 -4
  41. package/dist/esm5/classes/buffer/checkCall.js.map +1 -1
  42. package/dist/esm5/classes/buffer.js +5 -9
  43. package/dist/esm5/classes/buffer.js.map +1 -1
  44. package/dist/esm5/classes/domRoutines.js +107 -69
  45. package/dist/esm5/classes/domRoutines.js.map +1 -1
  46. package/dist/esm5/classes/logger.js +21 -21
  47. package/dist/esm5/classes/logger.js.map +1 -1
  48. package/dist/esm5/classes/paddings.js +5 -5
  49. package/dist/esm5/classes/paddings.js.map +1 -1
  50. package/dist/esm5/classes/state/cycle.js +2 -2
  51. package/dist/esm5/classes/state/cycle.js.map +1 -1
  52. package/dist/esm5/classes/viewport.js +10 -22
  53. package/dist/esm5/classes/viewport.js.map +1 -1
  54. package/dist/esm5/index.js.map +1 -1
  55. package/dist/esm5/inputs/validation.js +4 -4
  56. package/dist/esm5/inputs/validation.js.map +1 -1
  57. package/dist/esm5/interfaces/index.js.map +1 -1
  58. package/dist/esm5/interfaces/routines.js +2 -0
  59. package/dist/esm5/interfaces/routines.js.map +1 -0
  60. package/dist/esm5/interfaces/workflow.js.map +1 -1
  61. package/dist/esm5/processes/adapter/remove.js +1 -1
  62. package/dist/esm5/processes/adapter/remove.js.map +1 -1
  63. package/dist/esm5/processes/adjust.js +5 -5
  64. package/dist/esm5/processes/adjust.js.map +1 -1
  65. package/dist/esm5/processes/clip.js +5 -5
  66. package/dist/esm5/processes/clip.js.map +1 -1
  67. package/dist/esm5/processes/fetch.js +2 -2
  68. package/dist/esm5/processes/fetch.js.map +1 -1
  69. package/dist/esm5/processes/misc/base.js +1 -1
  70. package/dist/esm5/processes/misc/base.js.map +1 -1
  71. package/dist/esm5/processes/preClip.js +2 -2
  72. package/dist/esm5/processes/preClip.js.map +1 -1
  73. package/dist/esm5/processes/preFetch.js +5 -5
  74. package/dist/esm5/processes/preFetch.js.map +1 -1
  75. package/dist/esm5/processes/scroll.js +2 -2
  76. package/dist/esm5/processes/scroll.js.map +1 -1
  77. package/dist/esm5/scroller.js +5 -5
  78. package/dist/esm5/scroller.js.map +1 -1
  79. package/dist/esm5/version.js +1 -1
  80. package/dist/esm5/version.js.map +1 -1
  81. package/dist/esm5/workflow.js +12 -6
  82. package/dist/esm5/workflow.js.map +1 -1
  83. package/dist/typings/classes/domRoutines.d.ts +21 -19
  84. package/dist/typings/classes/logger.d.ts +1 -1
  85. package/dist/typings/classes/paddings.d.ts +2 -2
  86. package/dist/typings/classes/viewport.d.ts +1 -4
  87. package/dist/typings/index.d.ts +2 -2
  88. package/dist/typings/interfaces/index.d.ts +2 -1
  89. package/dist/typings/interfaces/routines.d.ts +157 -0
  90. package/dist/typings/interfaces/workflow.d.ts +3 -0
  91. package/dist/typings/scroller.d.ts +1 -1
  92. package/dist/typings/workflow.d.ts +1 -1
  93. package/package.json +18 -17
@@ -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.5.1 (2022-09-02T19:54:19.461Z)
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.5.1'
347
347
  };
348
348
 
349
349
  var instanceCount$1 = 0;
@@ -452,7 +452,7 @@ var ValidatorType;
452
452
  ValidatorType["enum"] = "must belong to {arg1} list";
453
453
  })(ValidatorType || (ValidatorType = {}));
454
454
  var getError = function (msg, args) {
455
- return (args || ['']).reduce(function (acc, arg, index) { return acc.replace("{arg" + (index + 1) + "}", arg); }, msg);
455
+ return (args || ['']).reduce(function (acc, arg, index) { return acc.replace("{arg".concat(index + 1, "}"), arg); }, msg);
456
456
  };
457
457
  var getNumber = function (value) {
458
458
  return typeof value === 'number' || (typeof value === 'string' && value !== '')
@@ -617,7 +617,7 @@ var onOneOf = function (tokens, must) { return function (value, context) {
617
617
  }
618
618
  var isAnotherPresent = context && Object.prototype.hasOwnProperty.call(context, token);
619
619
  if (isSet && isAnotherPresent) {
620
- errors.push(getError(err, [tokens.join('", "')]) + (" (" + token + " is present)"));
620
+ errors.push(getError(err, [tokens.join('", "')]) + " (".concat(token, " is present)"));
621
621
  break;
622
622
  }
623
623
  if (noOneIsPresent && isAnotherPresent) {
@@ -742,9 +742,9 @@ var ValidatedData = /** @class */ (function () {
742
742
  ValidatedData.prototype.setParam = function (token, value) {
743
743
  if (!value.isValid) {
744
744
  value.errors = !value.isSet
745
- ? ["\"" + token + "\" must be set"]
745
+ ? ["\"".concat(token, "\" must be set")]
746
746
  : value.errors.map(function (err) {
747
- return "\"" + token + "\" " + err;
747
+ return "\"".concat(token, "\" ").concat(err);
748
748
  });
749
749
  }
750
750
  this.params[token] = value;
@@ -1332,7 +1332,7 @@ var BaseAdapterProcessFactory = function (process) { var _a; return _a = /** @cl
1332
1332
  scroller.workflow.call({
1333
1333
  process: process,
1334
1334
  status: ProcessStatus.error,
1335
- payload: { error: "Wrong argument of the \"" + process + "\" method call" }
1335
+ payload: { error: "Wrong argument of the \"".concat(process, "\" method call") }
1336
1336
  });
1337
1337
  }
1338
1338
  }
@@ -1388,7 +1388,7 @@ var Scroll = /** @class */ (function (_super) {
1388
1388
  if (!scroll.syntheticFulfill || synthPos === position) {
1389
1389
  scroller.logger.log(function () { return [
1390
1390
  'skipping scroll', position,
1391
- "[" + (scroll.syntheticFulfill ? '' : 'pre-') + "synthetic]"
1391
+ "[".concat(scroll.syntheticFulfill ? '' : 'pre-', "synthetic]")
1392
1392
  ]; });
1393
1393
  return true;
1394
1394
  }
@@ -1410,7 +1410,7 @@ var Scroll = /** @class */ (function (_super) {
1410
1410
  direction === Direction.backward ? '\u2934' : '\u2935',
1411
1411
  position,
1412
1412
  shouldDelay ? (timeDiff + 'ms') : '0ms',
1413
- shouldDelay ? (alreadyDelayed ? 'delayed' : "/ " + delta + "ms delay") : ''
1413
+ shouldDelay ? (alreadyDelayed ? 'delayed' : "/ ".concat(delta, "ms delay")) : ''
1414
1414
  ]; });
1415
1415
  if (!shouldDelay) {
1416
1416
  if (scroll.scrollTimer) {
@@ -1906,7 +1906,7 @@ var Remove = /** @class */ (function (_super) {
1906
1906
  }
1907
1907
  }
1908
1908
  // virtual removal
1909
- scroller.logger.log(function () { return "going to remove " + toRemove.length + " item(s) virtually"; });
1909
+ scroller.logger.log(function () { return "going to remove ".concat(toRemove.length, " item(s) virtually"); });
1910
1910
  buffer.removeVirtually(toRemove, !!increase);
1911
1911
  buffer.checkDefaultSize();
1912
1912
  Remove.shiftFirstVisibleIndex(scroller, toRemove, !!increase);
@@ -2140,8 +2140,8 @@ var PreFetch = /** @class */ (function (_super) {
2140
2140
  startDelta += buffer.getSizeByIndex(index);
2141
2141
  }
2142
2142
  scroller.logger.log(function () { return __spreadArray([
2143
- "start delta is " + startDelta
2144
- ], __read((offset ? [" (+" + offset + " offset)"] : [])), false); });
2143
+ "start delta is ".concat(startDelta)
2144
+ ], __read((offset ? [" (+".concat(offset, " offset)")] : [])), false); });
2145
2145
  return startDelta;
2146
2146
  };
2147
2147
  PreFetch.setFirstIndex = function (scroller) {
@@ -2312,17 +2312,17 @@ var PreFetch = /** @class */ (function (_super) {
2312
2312
  direction_1 = fetch.last.index < buffer.items[0].$index ? Direction.backward : Direction.forward;
2313
2313
  }
2314
2314
  fetch.direction = direction_1;
2315
- scroller.logger.log(function () { return "fetch direction is \"" + direction_1 + "\""; });
2315
+ scroller.logger.log(function () { return "fetch direction is \"".concat(direction_1, "\""); });
2316
2316
  }
2317
2317
  };
2318
2318
  PreFetch.getStatus = function (scroller) {
2319
2319
  var _a = scroller.state, cycle = _a.cycle, fetch = _a.fetch;
2320
2320
  if (cycle.initiator === AdapterProcess.clip) {
2321
- scroller.logger.log(function () { return "going to skip fetch due to \"" + AdapterProcess.clip + "\" process"; });
2321
+ scroller.logger.log(function () { return "going to skip fetch due to \"".concat(AdapterProcess.clip, "\" process"); });
2322
2322
  return ProcessStatus.next;
2323
2323
  }
2324
2324
  if (fetch.shouldFetch) {
2325
- scroller.logger.log(function () { return "going to fetch " + fetch.count + " items started from index " + fetch.index; });
2325
+ scroller.logger.log(function () { return "going to fetch ".concat(fetch.count, " items started from index ").concat(fetch.index); });
2326
2326
  return ProcessStatus.next;
2327
2327
  }
2328
2328
  return ProcessStatus.done;
@@ -2340,8 +2340,8 @@ var Fetch = /** @class */ (function (_super) {
2340
2340
  var box = {
2341
2341
  success: function (data) {
2342
2342
  scroller.logger.log(function () {
2343
- return "resolved " + data.length + " items " +
2344
- ("(index = " + scroller.state.fetch.index + ", count = " + scroller.state.fetch.count + ")");
2343
+ return "resolved ".concat(data.length, " items ") +
2344
+ "(index = ".concat(scroller.state.fetch.index, ", count = ").concat(scroller.state.fetch.count, ")");
2345
2345
  });
2346
2346
  scroller.state.fetch.newItemsData = data;
2347
2347
  workflow.call({
@@ -2688,7 +2688,7 @@ var Adjust = /** @class */ (function (_super) {
2688
2688
  fwdSize += viewportSizeDiff;
2689
2689
  }
2690
2690
  scroller.logger.log(function () {
2691
- return inverse ? 'backward' : 'forward' + (" padding will be increased by " + viewportSizeDiff + " to fill the viewport");
2691
+ return inverse ? 'backward' : 'forward' + " padding will be increased by ".concat(viewportSizeDiff, " to fill the viewport");
2692
2692
  });
2693
2693
  }
2694
2694
  backward.size = bwdSize;
@@ -2700,7 +2700,7 @@ var Adjust = /** @class */ (function (_super) {
2700
2700
  var position = viewport.paddings.backward.size;
2701
2701
  // increase the position to meet the expectation of the first visible item
2702
2702
  if (!isNaN(fetch.firstVisible.index) && !isNaN(buffer.firstIndex)) {
2703
- scroller.logger.log("first index = " + fetch.firstVisible.index + ", delta = " + fetch.firstVisible.delta);
2703
+ scroller.logger.log("first index = ".concat(fetch.firstVisible.index, ", delta = ").concat(fetch.firstVisible.delta));
2704
2704
  var shouldCheckPreSizeExpectation_1 = fetch.shouldCheckPreSizeExpectation(buffer.lastIndex);
2705
2705
  buffer.items.forEach(function (item) {
2706
2706
  // 1) shift of the buffered items before the first visible item
@@ -2722,7 +2722,7 @@ var Adjust = /** @class */ (function (_super) {
2722
2722
  if (scroll.positionBeforeAsync !== null) {
2723
2723
  var diff = render.positionBefore - scroll.positionBeforeAsync;
2724
2724
  if (diff !== 0) {
2725
- scroller.logger.log("shift position due to fetch-render difference (" + diff + ")");
2725
+ scroller.logger.log("shift position due to fetch-render difference (".concat(diff, ")"));
2726
2726
  position += diff;
2727
2727
  }
2728
2728
  }
@@ -2753,7 +2753,7 @@ var Adjust = /** @class */ (function (_super) {
2753
2753
  var shift = Math.min(size, diff);
2754
2754
  if (shift) {
2755
2755
  viewport.paddings.forward.size += shift;
2756
- scroller.logger.log("increase fwd padding due to lack of items (" + diff + " -> " + shift + ")");
2756
+ scroller.logger.log("increase fwd padding due to lack of items (".concat(diff, " -> ").concat(shift, ")"));
2757
2757
  }
2758
2758
  };
2759
2759
  Adjust.setPosition = function (scroller, position, done) {
@@ -2770,7 +2770,7 @@ var Adjust = /** @class */ (function (_super) {
2770
2770
  if (inertiaDiff > 0) {
2771
2771
  position -= inertiaDiff;
2772
2772
  scroll.syntheticPosition = position;
2773
- diffLog = " (-" + inertiaDiff + ")";
2773
+ diffLog = " (-".concat(inertiaDiff, ")");
2774
2774
  }
2775
2775
  scroll.syntheticFulfill = true;
2776
2776
  viewport.scrollPosition = position;
@@ -2804,8 +2804,8 @@ var PreClip = /** @class */ (function (_super) {
2804
2804
  var firstIndex = fetch.first.indexBuffer;
2805
2805
  var lastIndex = fetch.last.indexBuffer;
2806
2806
  scroller.logger.log(function () {
2807
- return "looking for " + (fetch.direction ? 'anti-' + fetch.direction + ' ' : '') + "items " +
2808
- ("that are out of [" + firstIndex + ".." + lastIndex + "] range");
2807
+ return "looking for ".concat(fetch.direction ? 'anti-' + fetch.direction + ' ' : '', "items ") +
2808
+ "that are out of [".concat(firstIndex, "..").concat(lastIndex, "] range");
2809
2809
  });
2810
2810
  if (PreClip.isBackward(scroller, firstIndex)) {
2811
2811
  PreClip.prepareClipByDirection(scroller, Direction.backward, firstIndex);
@@ -2889,7 +2889,7 @@ var Clip = /** @class */ (function (_super) {
2889
2889
  var _a;
2890
2890
  var buffer = scroller.buffer, paddings = scroller.viewport.paddings, clip = scroller.state.clip, logger = scroller.logger;
2891
2891
  var size = (_a = {}, _a[Direction.backward] = 0, _a[Direction.forward] = 0, _a);
2892
- logger.stat("before clip (" + ++clip.callCount + ")");
2892
+ logger.stat("before clip (".concat(++clip.callCount, ")"));
2893
2893
  var itemsToRemove = buffer.items.filter(function (item) {
2894
2894
  if (!item.toRemove) {
2895
2895
  return false;
@@ -2917,10 +2917,10 @@ var Clip = /** @class */ (function (_super) {
2917
2917
  });
2918
2918
  return list.length
2919
2919
  ? [
2920
- "clipped " + list.length + " item(s) from Buffer" +
2921
- (size.backward ? ", +" + size.backward + " fwd px" : '') +
2922
- (size.forward ? ", +" + size.forward + " bwd px" : '') +
2923
- (", range: [" + list[0] + ".." + list[list.length - 1] + "]")
2920
+ "clipped ".concat(list.length, " item(s) from Buffer") +
2921
+ (size.backward ? ", +".concat(size.backward, " fwd px") : '') +
2922
+ (size.forward ? ", +".concat(size.forward, " bwd px") : '') +
2923
+ ", range: [".concat(list[0], "..").concat(list[list.length - 1], "]")
2924
2924
  ]
2925
2925
  : 'clipped 0 items from Buffer';
2926
2926
  });
@@ -2946,19 +2946,19 @@ var Logger = /** @class */ (function () {
2946
2946
  return arg;
2947
2947
  }
2948
2948
  else if (Array.isArray(arg)) {
2949
- return "[of " + arg.length + "]";
2949
+ return "[of ".concat(arg.length, "]");
2950
2950
  }
2951
2951
  return '{ ' + Object.keys(arg).join(', ') + ' }';
2952
2952
  })
2953
2953
  .join(', ');
2954
- _this.log("adapter: " + methodName + "(" + (params || '') + ")" + (add || ''));
2954
+ _this.log("adapter: ".concat(methodName, "(").concat(params || '', ")").concat(add || ''));
2955
2955
  };
2956
2956
  var settings = scroller.settings;
2957
2957
  this.debug = settings.debug;
2958
2958
  this.immediateLog = settings.immediateLog;
2959
2959
  this.logTime = settings.logTime;
2960
2960
  this.getTime = function () {
2961
- return scroller.state && " // time: " + scroller.state.time;
2961
+ return scroller.state && " // time: ".concat(scroller.state.time);
2962
2962
  };
2963
2963
  this.getStat = function () {
2964
2964
  var buffer = scroller.buffer, viewport = scroller.viewport;
@@ -2970,26 +2970,26 @@ var Logger = /** @class */ (function () {
2970
2970
  'fwd_p: ' + viewport.paddings.forward.size + ', ' +
2971
2971
  'default: ' + (buffer.defaultSize || 'no') + ', ' +
2972
2972
  'items: ' + buffer.getVisibleItemsCount() + ', ' +
2973
- 'range: ' + (first && last ? "[" + first.$index + ".." + last.$index + "]" : 'no');
2973
+ 'range: ' + (first && last ? "[".concat(first.$index, "..").concat(last.$index, "]") : 'no');
2974
2974
  };
2975
2975
  this.getFetchRange = function () {
2976
2976
  var _a = scroller.state.fetch, first = _a.first.index, last = _a.last.index;
2977
2977
  return !Number.isNaN(first) && !Number.isNaN(last)
2978
- ? "[" + first + ".." + last + "]"
2978
+ ? "[".concat(first, "..").concat(last, "]")
2979
2979
  : 'no';
2980
2980
  };
2981
2981
  this.getLoopId = function () { return scroller.state.cycle.loopId; };
2982
2982
  this.getLoopIdNext = function () { return scroller.state.cycle.loopIdNext; };
2983
2983
  this.getWorkflowCycleData = function () {
2984
- return settings.instanceIndex + "-" + scroller.state.cycle.count;
2984
+ return "".concat(settings.instanceIndex, "-").concat(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
- ("core: " + packageInfo.core.name + " v" + packageInfo.core.version + ", ") +
2990
- ("consumer: " + packageInfo.consumer.name + " v" + packageInfo.consumer.version + ", ") +
2991
- ("scroller instance: " + settings.instanceIndex + ", adapter ") +
2992
- (!adapter ? 'is not instantiated' : "instance: " + adapter.id);
2989
+ "core: ".concat(packageInfo.core.name, " v").concat(packageInfo.core.version, ", ") +
2990
+ "consumer: ".concat(packageInfo.consumer.name, " v").concat(packageInfo.consumer.version, ", ") +
2991
+ "scroller instance: ".concat(settings.instanceIndex, ", adapter ") +
2992
+ (!adapter ? 'is not instantiated' : "instance: ".concat(adapter.id));
2993
2993
  });
2994
2994
  }
2995
2995
  Logger.prototype.object = function (str, obj, stringify) {
@@ -3030,20 +3030,20 @@ var Logger = /** @class */ (function () {
3030
3030
  'color: #888; border: dashed #888 0; border-bottom-width: 0px',
3031
3031
  'color: #000; border-width: 0'
3032
3032
  ];
3033
- this.log(function () { return __spreadArray(['%cstat' + (str ? " " + str : '') + ',%c ' + _this.getStat()], __read(logStyles_1), false); });
3033
+ this.log(function () { return __spreadArray(['%cstat' + (str ? " ".concat(str) : '') + ',%c ' + _this.getStat()], __read(logStyles_1), false); });
3034
3034
  }
3035
3035
  };
3036
3036
  Logger.prototype.fetch = function (str) {
3037
3037
  var _this = this;
3038
3038
  if (this.debug) {
3039
- var _text_1 = 'fetch interval' + (str ? " " + str : '');
3039
+ var _text_1 = 'fetch interval' + (str ? " ".concat(str) : '');
3040
3040
  var logStyles_2 = ['color: #888', 'color: #000'];
3041
- this.log(function () { return __spreadArray(["%c" + _text_1 + ": %c" + _this.getFetchRange()], __read(logStyles_2), false); });
3041
+ this.log(function () { return __spreadArray(["%c".concat(_text_1, ": %c").concat(_this.getFetchRange())], __read(logStyles_2), false); });
3042
3042
  }
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) {
@@ -3054,13 +3054,13 @@ var Logger = /** @class */ (function () {
3054
3054
  // inner loop start-end log
3055
3055
  var loopLog = [];
3056
3056
  if (process === CommonProcess.init && status === ProcessStatus.next) {
3057
- loopLog.push("%c---=== loop " + this.getLoopIdNext() + " start");
3057
+ loopLog.push("%c---=== loop ".concat(this.getLoopIdNext(), " start"));
3058
3058
  }
3059
3059
  else if (process === CommonProcess.end) {
3060
- loopLog.push("%c---=== loop " + this.getLoopId() + " done");
3060
+ loopLog.push("%c---=== loop ".concat(this.getLoopId(), " done"));
3061
3061
  var parent_1 = payload && payload.process;
3062
3062
  if (status === ProcessStatus.next && (parent_1 !== AdapterProcess.reset && parent_1 !== AdapterProcess.reload)) {
3063
- loopLog[0] += ", loop " + this.getLoopIdNext() + " start";
3063
+ loopLog[0] += ", loop ".concat(this.getLoopIdNext(), " start");
3064
3064
  }
3065
3065
  }
3066
3066
  if (loopLog.length) {
@@ -3071,14 +3071,14 @@ var Logger = /** @class */ (function () {
3071
3071
  if (start === void 0) { start = true; }
3072
3072
  var logData = this.getWorkflowCycleData();
3073
3073
  var border = start ? '1px 0 0 1px' : '0 0 1px 1px';
3074
- var logStyles = "color: #0000aa; border: solid #555 1px; border-width: " + border + "; margin-left: -2px";
3075
- this.log(function () { return ["%c ~~~ WF Cycle " + logData + " " + (start ? 'STARTED' : 'FINALIZED') + " ~~~ ", logStyles]; });
3074
+ var logStyles = "color: #0000aa; border: solid #555 1px; border-width: ".concat(border, "; margin-left: -2px");
3075
+ this.log(function () { return ["%c ~~~ WF Cycle ".concat(logData, " ").concat(start ? 'STARTED' : 'FINALIZED', " ~~~ "), logStyles]; });
3076
3076
  };
3077
3077
  Logger.prototype.logError = function (str) {
3078
3078
  var _this = this;
3079
3079
  if (this.debug) {
3080
3080
  var logStyles_3 = ['color: #a00;', 'color: #000'];
3081
- this.log(function () { return __spreadArray(['error:%c' + (str ? " " + str : '') + ("%c (loop " + _this.getLoopIdNext() + ")")], __read(logStyles_3), false); });
3081
+ this.log(function () { return __spreadArray(['error:%c' + (str ? " ".concat(str) : '') + "%c (loop ".concat(_this.getLoopIdNext(), ")")], __read(logStyles_3), false); });
3082
3082
  }
3083
3083
  };
3084
3084
  Logger.prototype.log = function () {
@@ -3138,64 +3138,85 @@ 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, CustomRoutines) {
3142
+ var _this = this;
3143
+ this.element = element;
3144
+ this.settings = {
3145
+ viewport: settings.viewport,
3146
+ horizontal: settings.horizontal,
3147
+ window: settings.windowViewport
3148
+ };
3149
+ // provide custom overrides for IRoutines methods
3150
+ if (CustomRoutines) {
3151
+ var self_1 = this;
3152
+ var routines_1 = new CustomRoutines(element, this.settings);
3153
+ Object.getOwnPropertyNames(Object.getPrototypeOf(routines_1))
3154
+ .filter(function (method) {
3155
+ return method !== 'constructor' &&
3156
+ typeof routines_1[method] === 'function' &&
3157
+ typeof self_1[method] === 'function';
3158
+ })
3159
+ .forEach(function (method) {
3160
+ return self_1[method] = function () {
3161
+ var args = [];
3162
+ for (var _i = 0; _i < arguments.length; _i++) {
3163
+ args[_i] = arguments[_i];
3164
+ }
3165
+ return routines_1[method].apply(_this, args);
3166
+ };
3167
+ });
3168
+ }
3169
+ // initialization
3170
+ this.viewport = this.getViewportElement();
3171
+ this.onInit(settings);
3145
3172
  }
3146
3173
  Routines.prototype.checkElement = function (element) {
3147
3174
  if (!element) {
3148
3175
  throw new Error('HTML element is not defined');
3149
3176
  }
3150
3177
  };
3151
- Routines.prototype.getHostElement = function (element) {
3152
- if (this.window) {
3178
+ Routines.prototype.getViewportElement = function () {
3179
+ if (this.settings.window) {
3153
3180
  return document.documentElement;
3154
3181
  }
3155
- if (this.viewport) {
3156
- return this.viewport;
3182
+ if (this.settings.viewport) {
3183
+ return this.settings.viewport;
3157
3184
  }
3158
- this.checkElement(element);
3159
- var parent = element.parentElement;
3185
+ this.checkElement(this.element);
3186
+ var parent = this.element.parentElement;
3160
3187
  this.checkElement(parent);
3161
3188
  return parent;
3162
3189
  };
3163
- Routines.prototype.getScrollEventReceiver = function (element) {
3164
- if (this.window) {
3165
- return window;
3190
+ Routines.prototype.onInit = function (settings) {
3191
+ if (settings.windowViewport) {
3192
+ if ('scrollRestoration' in history) {
3193
+ history.scrollRestoration = 'manual';
3194
+ }
3166
3195
  }
3167
- return this.getHostElement(element);
3168
- };
3169
- Routines.prototype.setupScrollRestoration = function () {
3170
- if ('scrollRestoration' in history) {
3171
- history.scrollRestoration = 'manual';
3196
+ if (settings.dismissOverflowAnchor) {
3197
+ this.viewport.style.overflowAnchor = 'none';
3172
3198
  }
3173
3199
  };
3174
- Routines.prototype.dismissOverflowAnchor = function (element) {
3175
- this.checkElement(element);
3176
- element.style.overflowAnchor = 'none';
3177
- };
3178
3200
  Routines.prototype.findElementBySelector = function (element, selector) {
3179
3201
  this.checkElement(element);
3180
3202
  return element.querySelector(selector);
3181
3203
  };
3182
- Routines.prototype.findPaddingElement = function (element, direction) {
3183
- return this.findElementBySelector(element, "[data-padding-" + direction + "]");
3204
+ Routines.prototype.findPaddingElement = function (direction) {
3205
+ return this.findElementBySelector(this.element, "[data-padding-".concat(direction, "]"));
3184
3206
  };
3185
- Routines.prototype.findItemElement = function (element, id) {
3186
- return this.findElementBySelector(element, "[data-sid=\"" + id + "\"]");
3207
+ Routines.prototype.findItemElement = function (id) {
3208
+ return this.findElementBySelector(this.element, "[data-sid=\"".concat(id, "\"]"));
3187
3209
  };
3188
- Routines.prototype.getScrollPosition = function (element) {
3189
- if (this.window) {
3190
- return window.pageYOffset;
3210
+ Routines.prototype.getScrollPosition = function () {
3211
+ if (this.settings.window) {
3212
+ return this.settings.horizontal ? window.pageXOffset : window.pageYOffset;
3191
3213
  }
3192
- this.checkElement(element);
3193
- return element[this.horizontal ? 'scrollLeft' : 'scrollTop'];
3214
+ return this.viewport[this.settings.horizontal ? 'scrollLeft' : 'scrollTop'];
3194
3215
  };
3195
- Routines.prototype.setScrollPosition = function (element, value) {
3216
+ Routines.prototype.setScrollPosition = function (value) {
3196
3217
  value = Math.max(0, value);
3197
- if (this.window) {
3198
- if (this.horizontal) {
3218
+ if (this.settings.window) {
3219
+ if (this.settings.horizontal) {
3199
3220
  window.scrollTo(value, window.scrollY);
3200
3221
  }
3201
3222
  else {
@@ -3203,49 +3224,62 @@ var Routines = /** @class */ (function () {
3203
3224
  }
3204
3225
  return;
3205
3226
  }
3206
- this.checkElement(element);
3207
- element[this.horizontal ? 'scrollLeft' : 'scrollTop'] = value;
3227
+ this.viewport[this.settings.horizontal ? 'scrollLeft' : 'scrollTop'] = value;
3208
3228
  };
3209
- Routines.prototype.getParams = function (element, doNotBind) {
3229
+ Routines.prototype.getElementParams = function (element) {
3210
3230
  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
3231
  return element.getBoundingClientRect();
3226
3232
  };
3227
- Routines.prototype.getSize = function (element, doNotBind) {
3228
- return this.getParams(element, doNotBind)[this.horizontal ? 'width' : 'height'];
3233
+ Routines.prototype.getWindowParams = function () {
3234
+ var _a = this.viewport, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight, clientLeft = _a.clientLeft, clientTop = _a.clientTop;
3235
+ return {
3236
+ 'height': clientHeight,
3237
+ 'width': clientWidth,
3238
+ 'top': clientTop,
3239
+ 'bottom': clientTop + clientHeight,
3240
+ 'left': clientLeft,
3241
+ 'right': clientLeft + clientWidth,
3242
+ 'x': clientLeft,
3243
+ 'y': clientTop,
3244
+ 'toJSON': function () { return null; },
3245
+ };
3246
+ };
3247
+ Routines.prototype.getSize = function (element) {
3248
+ return this.getElementParams(element)[this.settings.horizontal ? 'width' : 'height'];
3249
+ };
3250
+ Routines.prototype.getScrollerSize = function () {
3251
+ return this.getElementParams(this.element)[this.settings.horizontal ? 'width' : 'height'];
3252
+ };
3253
+ Routines.prototype.getViewportSize = function () {
3254
+ if (this.settings.window) {
3255
+ return this.getWindowParams()[this.settings.horizontal ? 'width' : 'height'];
3256
+ }
3257
+ return this.getSize(this.viewport);
3229
3258
  };
3230
3259
  Routines.prototype.getSizeStyle = function (element) {
3231
3260
  this.checkElement(element);
3232
- var size = element.style[this.horizontal ? 'width' : 'height'];
3261
+ var size = element.style[this.settings.horizontal ? 'width' : 'height'];
3233
3262
  return parseFloat(size) || 0;
3234
3263
  };
3235
3264
  Routines.prototype.setSizeStyle = function (element, value) {
3236
3265
  this.checkElement(element);
3237
3266
  value = Math.max(0, Math.round(value));
3238
- element.style[this.horizontal ? 'width' : 'height'] = value + "px";
3267
+ element.style[this.settings.horizontal ? 'width' : 'height'] = "".concat(value, "px");
3239
3268
  };
3240
- Routines.prototype.getEdge = function (element, direction, doNotBind) {
3241
- var params = this.getParams(element, doNotBind);
3269
+ Routines.prototype.getEdge = function (element, direction) {
3270
+ var horizontal = this.settings.horizontal;
3271
+ var params = this.getElementParams(element);
3242
3272
  var isFwd = direction === Direction.forward;
3243
- return params[isFwd ? (this.horizontal ? 'right' : 'bottom') : (this.horizontal ? 'left' : 'top')];
3273
+ return params[isFwd ? (horizontal ? 'right' : 'bottom') : (horizontal ? 'left' : 'top')];
3244
3274
  };
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);
3275
+ Routines.prototype.getViewportEdge = function (direction) {
3276
+ var _a = this.settings, window = _a.window, horizontal = _a.horizontal;
3277
+ if (window) {
3278
+ var params = this.getWindowParams();
3279
+ var isFwd = direction === Direction.forward;
3280
+ return params[isFwd ? (horizontal ? 'right' : 'bottom') : (horizontal ? 'left' : 'top')];
3281
+ }
3282
+ return this.getEdge(this.viewport, direction);
3249
3283
  };
3250
3284
  Routines.prototype.makeElementVisible = function (element) {
3251
3285
  this.checkElement(element);
@@ -3257,9 +3291,12 @@ var Routines = /** @class */ (function () {
3257
3291
  this.checkElement(element);
3258
3292
  element.style.display = 'none';
3259
3293
  };
3260
- Routines.prototype.getOffset = function (element) {
3261
- this.checkElement(element);
3262
- return (this.horizontal ? element.offsetLeft : element.offsetTop) || 0;
3294
+ Routines.prototype.getOffset = function () {
3295
+ var _this = this;
3296
+ var get = function (element) {
3297
+ return (_this.settings.horizontal ? element.offsetLeft : element.offsetTop) || 0;
3298
+ };
3299
+ return get(this.element) - (!this.settings.window ? get(this.viewport) : 0);
3263
3300
  };
3264
3301
  Routines.prototype.scrollTo = function (element, argument) {
3265
3302
  this.checkElement(element);
@@ -3273,16 +3310,17 @@ var Routines = /** @class */ (function () {
3273
3310
  var animationFrameId = requestAnimationFrame(function () { return cb(); });
3274
3311
  return function () { return cancelAnimationFrame(animationFrameId); };
3275
3312
  };
3276
- Routines.prototype.onScroll = function (element, handler) {
3277
- element.addEventListener('scroll', handler);
3278
- return function () { return element.removeEventListener('scroll', handler); };
3313
+ Routines.prototype.onScroll = function (handler) {
3314
+ var eventReceiver = this.settings.window ? window : this.viewport;
3315
+ eventReceiver.addEventListener('scroll', handler);
3316
+ return function () { return eventReceiver.removeEventListener('scroll', handler); };
3279
3317
  };
3280
3318
  return Routines;
3281
3319
  }());
3282
3320
 
3283
3321
  var Padding = /** @class */ (function () {
3284
- function Padding(element, direction, routines) {
3285
- var found = routines.findPaddingElement(element, direction);
3322
+ function Padding(direction, routines) {
3323
+ var found = routines.findPaddingElement(direction);
3286
3324
  routines.checkElement(found);
3287
3325
  this.element = found;
3288
3326
  this.direction = direction;
@@ -3304,10 +3342,10 @@ var Padding = /** @class */ (function () {
3304
3342
  return Padding;
3305
3343
  }());
3306
3344
  var Paddings = /** @class */ (function () {
3307
- function Paddings(element, routines, settings) {
3345
+ function Paddings(routines, settings) {
3308
3346
  this.settings = settings;
3309
- this.forward = new Padding(element, Direction.forward, routines);
3310
- this.backward = new Padding(element, Direction.backward, routines);
3347
+ this.forward = new Padding(Direction.forward, routines);
3348
+ this.backward = new Padding(Direction.backward, routines);
3311
3349
  }
3312
3350
  Paddings.prototype.byDirection = function (direction, opposite) {
3313
3351
  return direction === Direction.backward
@@ -3359,21 +3397,12 @@ var Paddings = /** @class */ (function () {
3359
3397
  }());
3360
3398
 
3361
3399
  var Viewport = /** @class */ (function () {
3362
- function Viewport(element, settings, routines, state, logger) {
3363
- this.element = element;
3400
+ function Viewport(settings, routines, state, logger) {
3364
3401
  this.settings = settings;
3365
3402
  this.routines = routines;
3366
3403
  this.state = state;
3367
3404
  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);
3405
+ this.paddings = new Paddings(this.routines, settings);
3377
3406
  }
3378
3407
  Viewport.prototype.reset = function (startIndex) {
3379
3408
  this.setOffset();
@@ -3387,16 +3416,16 @@ var Viewport = /** @class */ (function () {
3387
3416
  this.logger.log(function () { return ['setting scroll position at', value, '[cancelled]']; });
3388
3417
  return value;
3389
3418
  }
3390
- this.routines.setScrollPosition(this.hostElement, value);
3419
+ this.routines.setScrollPosition(value);
3391
3420
  var position = this.scrollPosition;
3392
3421
  this.logger.log(function () { return __spreadArray([
3393
3422
  'setting scroll position at', position
3394
- ], __read((position !== value ? ["(" + value + ")"] : [])), false); });
3423
+ ], __read((position !== value ? ["(".concat(value, ")")] : [])), false); });
3395
3424
  return position;
3396
3425
  };
3397
3426
  Object.defineProperty(Viewport.prototype, "scrollPosition", {
3398
3427
  get: function () {
3399
- return this.routines.getScrollPosition(this.hostElement);
3428
+ return this.routines.getScrollPosition();
3400
3429
  },
3401
3430
  set: function (value) {
3402
3431
  this.setPosition(value);
@@ -3405,10 +3434,10 @@ var Viewport = /** @class */ (function () {
3405
3434
  configurable: true
3406
3435
  });
3407
3436
  Viewport.prototype.getSize = function () {
3408
- return this.routines.getSize(this.hostElement, true);
3437
+ return this.routines.getViewportSize();
3409
3438
  };
3410
3439
  Viewport.prototype.getScrollableSize = function () {
3411
- return this.routines.getSize(this.element);
3440
+ return this.routines.getScrollerSize();
3412
3441
  };
3413
3442
  Viewport.prototype.getMaxScrollPosition = function () {
3414
3443
  return this.getScrollableSize() - this.getSize();
@@ -3417,16 +3446,13 @@ var Viewport = /** @class */ (function () {
3417
3446
  return this.getSize() * this.settings.padding;
3418
3447
  };
3419
3448
  Viewport.prototype.getEdge = function (direction) {
3420
- return this.routines.getEdge(this.hostElement, direction, true);
3449
+ return this.routines.getViewportEdge(direction);
3421
3450
  };
3422
3451
  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
- }
3452
+ this.offset = this.routines.getOffset();
3427
3453
  };
3428
3454
  Viewport.prototype.findItemElementById = function (id) {
3429
- return this.routines.findItemElement(this.element, id);
3455
+ return this.routines.findItemElement(id);
3430
3456
  };
3431
3457
  Viewport.prototype.getEdgeVisibleItem = function (items, direction) {
3432
3458
  var bwd = direction === Direction.backward;
@@ -3640,7 +3666,7 @@ var Cache = /** @class */ (function () {
3640
3666
  Cache.prototype.recalculateDefaultSize = function () {
3641
3667
  var _this = this;
3642
3668
  if (this.defaultSize.recalculate(this.size)) {
3643
- this.logger.log(function () { return "default size has been updated: " + _this.defaultSize.get(); });
3669
+ this.logger.log(function () { return "default size has been updated: ".concat(_this.defaultSize.get()); });
3644
3670
  return true;
3645
3671
  }
3646
3672
  return false;
@@ -3859,7 +3885,7 @@ var CheckBufferCall = /** @class */ (function () {
3859
3885
  this.logger.log('no items to fill the buffer; wrong indexes');
3860
3886
  return false;
3861
3887
  }
3862
- this.logger.log(function () { return "going to fill the buffer with " + items.length + " item(s)"; });
3888
+ this.logger.log(function () { return "going to fill the buffer with ".concat(items.length, " item(s)"); });
3863
3889
  return true;
3864
3890
  };
3865
3891
  CheckBufferCall.prototype.insertInBuffer = function (predicate, before, after) {
@@ -3883,18 +3909,18 @@ var CheckBufferCall = /** @class */ (function () {
3883
3909
  if (index < finiteAbsMinIndex || index > finiteAbsMaxIndex) {
3884
3910
  this.logger.log(function () {
3885
3911
  return 'no items to insert virtually; ' +
3886
- ("selected index (" + index + ") does not match virtual area [" + finiteAbsMinIndex + ".." + finiteAbsMaxIndex + "]");
3912
+ "selected index (".concat(index, ") does not match virtual area [").concat(finiteAbsMinIndex, "..").concat(finiteAbsMaxIndex, "]");
3887
3913
  });
3888
3914
  return false;
3889
3915
  }
3890
3916
  var before = direction === Direction.backward;
3891
3917
  if (!(index < firstIndex + (before ? 1 : 0) || index > lastIndex - (before ? 0 : 1))) {
3892
3918
  this.logger.log(function () {
3893
- return "no items to insert virtually; selected index (" + index + ") belongs Buffer [" + firstIndex + ".." + lastIndex + "]";
3919
+ return "no items to insert virtually; selected index (".concat(index, ") belongs Buffer [").concat(firstIndex, "..").concat(lastIndex, "]");
3894
3920
  });
3895
3921
  return false;
3896
3922
  }
3897
- this.logger.log(function () { return "going to insert " + items.length + " item(s) virtually"; });
3923
+ this.logger.log(function () { return "going to insert ".concat(items.length, " item(s) virtually"); });
3898
3924
  return true;
3899
3925
  };
3900
3926
  return CheckBufferCall;
@@ -3938,15 +3964,15 @@ var Buffer = /** @class */ (function () {
3938
3964
  var start = this.startIndexUser;
3939
3965
  var index = Number(newStartIndex);
3940
3966
  if (Number.isNaN(index)) {
3941
- this.logger.log(function () { return "fallback startIndex to settings.startIndex (" + start + ")"; });
3967
+ this.logger.log(function () { return "fallback startIndex to settings.startIndex (".concat(start, ")"); });
3942
3968
  index = start;
3943
3969
  }
3944
3970
  if (index < min) {
3945
- this.logger.log(function () { return "setting startIndex to settings.minIndex (" + min + ") because " + index + " < " + min; });
3971
+ this.logger.log(function () { return "setting startIndex to settings.minIndex (".concat(min, ") because ").concat(index, " < ").concat(min); });
3946
3972
  index = min;
3947
3973
  }
3948
3974
  if (index > max) {
3949
- this.logger.log(function () { return "setting startIndex to settings.maxIndex (" + max + ") because " + index + " > " + max; });
3975
+ this.logger.log(function () { return "setting startIndex to settings.maxIndex (".concat(max, ") because ").concat(index, " > ").concat(max); });
3950
3976
  index = max;
3951
3977
  }
3952
3978
  this.startIndex = index;
@@ -4282,15 +4308,11 @@ var Buffer = /** @class */ (function () {
4282
4308
  };
4283
4309
  Buffer.prototype.getFirstVisibleItem = function () {
4284
4310
  var index = this.getFirstVisibleItemIndex();
4285
- if (index >= 0) {
4286
- return this.items[index];
4287
- }
4311
+ return index >= 0 ? this.items[index] : void 0;
4288
4312
  };
4289
4313
  Buffer.prototype.getLastVisibleItem = function () {
4290
4314
  var index = this.getLastVisibleItemIndex();
4291
- if (index >= 0) {
4292
- return this.items[index];
4293
- }
4315
+ return index >= 0 ? this.items[index] : void 0;
4294
4316
  };
4295
4317
  Buffer.prototype.getEdgeVisibleItem = function (direction, opposite) {
4296
4318
  return direction === (!opposite ? Direction.forward : Direction.backward) ?
@@ -4347,14 +4369,14 @@ var WorkflowCycleModel = /** @class */ (function () {
4347
4369
  }
4348
4370
  Object.defineProperty(WorkflowCycleModel.prototype, "loopId", {
4349
4371
  get: function () {
4350
- return this.instanceIndex + "-" + this.count + "-" + this.innerLoop.total;
4372
+ return "".concat(this.instanceIndex, "-").concat(this.count, "-").concat(this.innerLoop.total);
4351
4373
  },
4352
4374
  enumerable: false,
4353
4375
  configurable: true
4354
4376
  });
4355
4377
  Object.defineProperty(WorkflowCycleModel.prototype, "loopIdNext", {
4356
4378
  get: function () {
4357
- return this.instanceIndex + "-" + this.count + "-" + (this.innerLoop.total + 1);
4379
+ return "".concat(this.instanceIndex, "-").concat(this.count, "-").concat(this.innerLoop.total + 1);
4358
4380
  },
4359
4381
  enumerable: false,
4360
4382
  configurable: true
@@ -4968,7 +4990,7 @@ var Adapter = /** @class */ (function () {
4968
4990
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4969
4991
  Adapter.prototype.reset = function (options) {
4970
4992
  this.reloadCounter++;
4971
- this.logger.logAdapterMethod('reset', options, " of " + this.reloadId);
4993
+ this.logger.logAdapterMethod('reset', options, " of ".concat(this.reloadId));
4972
4994
  this.workflow.call({
4973
4995
  process: AdapterProcess.reset,
4974
4996
  status: ProcessStatus.start,
@@ -4978,7 +5000,7 @@ var Adapter = /** @class */ (function () {
4978
5000
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4979
5001
  Adapter.prototype.reload = function (options) {
4980
5002
  this.reloadCounter++;
4981
- this.logger.logAdapterMethod('reload', options, " of " + this.reloadId);
5003
+ this.logger.logAdapterMethod('reload', options, " of ".concat(this.reloadId));
4982
5004
  this.workflow.call({
4983
5005
  process: AdapterProcess.reload,
4984
5006
  status: ProcessStatus.start,
@@ -5085,7 +5107,7 @@ var Adapter = /** @class */ (function () {
5085
5107
  });
5086
5108
  }).then(function (immediate) {
5087
5109
  var success = reloadId === _this.reloadId;
5088
- _this.logger.log(function () { return !success ? "relax promise cancelled due to " + reloadId + " != " + _this.reloadId : void 0; });
5110
+ _this.logger.log(function () { return !success ? "relax promise cancelled due to ".concat(reloadId, " != ").concat(_this.reloadId) : void 0; });
5089
5111
  return {
5090
5112
  immediate: immediate,
5091
5113
  success: success,
@@ -5096,7 +5118,7 @@ var Adapter = /** @class */ (function () {
5096
5118
  Adapter.prototype.relax = function (callback) {
5097
5119
  var _this = this;
5098
5120
  var reloadId = this.reloadId;
5099
- this.logger.logAdapterMethod('relax', callback, " of " + reloadId);
5121
+ this.logger.logAdapterMethod('relax', callback, " of ".concat(reloadId));
5100
5122
  if (!this.init) {
5101
5123
  return Promise.resolve(methodPreResult);
5102
5124
  }
@@ -5118,21 +5140,21 @@ var INVALID_DATASOURCE_PREFIX = 'Invalid datasource:';
5118
5140
  var instanceCount = 0;
5119
5141
  var Scroller = /** @class */ (function () {
5120
5142
  function Scroller(_a) {
5121
- var datasource = _a.datasource, consumer = _a.consumer, element = _a.element, workflow = _a.workflow, scroller = _a.scroller;
5143
+ var datasource = _a.datasource, consumer = _a.consumer, element = _a.element, workflow = _a.workflow, CustomRoutines = _a.Routines, scroller = _a.scroller;
5122
5144
  var get = validate(datasource, DATASOURCE).params.get;
5123
5145
  if (!get.isValid) {
5124
- throw new Error(INVALID_DATASOURCE_PREFIX + " " + get.errors[0]);
5146
+ throw new Error("".concat(INVALID_DATASOURCE_PREFIX, " ").concat(get.errors[0]));
5125
5147
  }
5126
5148
  var packageInfo = scroller ? scroller.state.packageInfo : { consumer: consumer, core: core };
5127
- element = scroller ? scroller.viewport.element : element;
5149
+ element = scroller ? scroller.routines.element : element;
5128
5150
  workflow = scroller ? scroller.workflow : workflow;
5129
5151
  this.workflow = workflow;
5130
5152
  this.settings = new Settings(datasource.settings, datasource.devSettings, ++instanceCount);
5131
5153
  this.logger = new Logger(this, packageInfo, datasource.adapter);
5132
- this.routines = new Routines(this.settings);
5154
+ this.routines = new Routines(element, this.settings, CustomRoutines);
5133
5155
  this.state = new State(packageInfo, this.settings, scroller ? scroller.state : void 0);
5134
5156
  this.buffer = new Buffer(this.settings, workflow.onDataChanged, this.logger);
5135
- this.viewport = new Viewport(element, this.settings, this.routines, this.state, this.logger);
5157
+ this.viewport = new Viewport(this.settings, this.routines, this.state, this.logger);
5136
5158
  this.logger.object('vscroll settings object', this.settings, true);
5137
5159
  this.initDatasource(datasource, scroller);
5138
5160
  }
@@ -5391,7 +5413,7 @@ var runStateMachine = function (_a) {
5391
5413
  var Workflow = /** @class */ (function () {
5392
5414
  function Workflow(_a) {
5393
5415
  var _this = this;
5394
- var element = _a.element, datasource = _a.datasource, consumer = _a.consumer, run = _a.run;
5416
+ var element = _a.element, datasource = _a.datasource, consumer = _a.consumer, run = _a.run, Routines = _a.Routines;
5395
5417
  this.isInitialized = false;
5396
5418
  this.initTimer = null;
5397
5419
  this.adapterRun$ = new Reactive();
@@ -5406,7 +5428,13 @@ var Workflow = /** @class */ (function () {
5406
5428
  done: this.done.bind(this),
5407
5429
  onError: this.onError.bind(this)
5408
5430
  };
5409
- this.scroller = new Scroller({ element: element, datasource: datasource, consumer: consumer, workflow: this.getUpdater() });
5431
+ this.scroller = new Scroller({
5432
+ element: element,
5433
+ datasource: datasource,
5434
+ consumer: consumer,
5435
+ workflow: this.getUpdater(),
5436
+ Routines: Routines
5437
+ });
5410
5438
  if (this.scroller.settings.initializeDelay) {
5411
5439
  this.initTimer = setTimeout(function () {
5412
5440
  _this.initTimer = null;
@@ -5427,13 +5455,13 @@ var Workflow = /** @class */ (function () {
5427
5455
  status: ProcessStatus.start
5428
5456
  });
5429
5457
  // set up scroll event listener
5430
- var _a = this.scroller, scrollEventReceiver = _a.viewport.scrollEventReceiver, routines = _a.routines;
5458
+ var routines = this.scroller.routines;
5431
5459
  var onScrollHandler = function (event) { return _this.callWorkflow({
5432
5460
  process: CommonProcess.scroll,
5433
5461
  status: ProcessStatus.start,
5434
5462
  payload: { event: event }
5435
5463
  }); };
5436
- this.offScroll = routines.onScroll(scrollEventReceiver, onScrollHandler);
5464
+ this.offScroll = routines.onScroll(onScrollHandler);
5437
5465
  };
5438
5466
  Workflow.prototype.changeItems = function (items) {
5439
5467
  this.propagateChanges(items);
@@ -5461,7 +5489,7 @@ var Workflow = /** @class */ (function () {
5461
5489
  '%cfire%c'
5462
5490
  ], ['color: #cc7777;', 'color: #000000;'], false), [
5463
5491
  process,
5464
- "\"" + status + "\""
5492
+ "\"".concat(status, "\"")
5465
5493
  ], false), __read((payload !== void 0 ? [payload] : [])), false); });
5466
5494
  }
5467
5495
  this.scroller.logger.logProcess(data);
@@ -5517,7 +5545,7 @@ var Workflow = /** @class */ (function () {
5517
5545
  workflow.call.interrupted = true;
5518
5546
  this.scroller.workflow = this.getUpdater();
5519
5547
  this.interruptionCount++;
5520
- logger_1.log(function () { return "workflow had been interrupted by the " + process + " process (" + _this.interruptionCount + ")"; });
5548
+ logger_1.log(function () { return "workflow had been interrupted by the ".concat(process, " process (").concat(_this.interruptionCount, ")"); });
5521
5549
  }
5522
5550
  if (datasource) { // Scroller re-initialization case
5523
5551
  this.scroller.adapter.relax(function () {