vscroll 1.6.1 → 1.6.3

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 (34) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -12
  3. package/dist/bundles/vscroll.esm5.js +17 -6
  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 +17 -6
  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 +18 -7
  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/inputs/adapter.js +12 -2
  16. package/dist/esm2015/inputs/adapter.js.map +1 -1
  17. package/dist/esm2015/interfaces/adapter.js.map +1 -1
  18. package/dist/esm2015/processes/adapter/append.js +2 -1
  19. package/dist/esm2015/processes/adapter/append.js.map +1 -1
  20. package/dist/esm2015/processes/adapter/insert.js +1 -1
  21. package/dist/esm2015/processes/adapter/insert.js.map +1 -1
  22. package/dist/esm2015/version.js +1 -1
  23. package/dist/esm2015/version.js.map +1 -1
  24. package/dist/esm5/inputs/adapter.js +12 -2
  25. package/dist/esm5/inputs/adapter.js.map +1 -1
  26. package/dist/esm5/interfaces/adapter.js.map +1 -1
  27. package/dist/esm5/processes/adapter/append.js +2 -1
  28. package/dist/esm5/processes/adapter/append.js.map +1 -1
  29. package/dist/esm5/processes/adapter/insert.js +1 -1
  30. package/dist/esm5/processes/adapter/insert.js.map +1 -1
  31. package/dist/esm5/version.js +1 -1
  32. package/dist/esm5/version.js.map +1 -1
  33. package/dist/typings/interfaces/adapter.d.ts +3 -0
  34. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Denis Hilt (https://github.com/dhilt)
3
+ Copyright (c) 2025 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
@@ -73,7 +73,7 @@ interface WorkflowParams<ItemData> {
73
73
  }
74
74
  ```
75
75
 
76
- This is a TypeScript definition, but speaking of JavaScript, an argument object must contain 4 fields described below.
76
+ This is a TypeScript definition, but speaking of JavaScript, an argument object must contain 4 mandatory and 1 optional fields described below.
77
77
 
78
78
  ### 1. Consumer
79
79
 
@@ -176,13 +176,14 @@ Each item (in both `newItems` and `oldItems` lists) is an instance of the [Item
176
176
 
177
177
  `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.
178
178
 
179
- There are some requirements on how the items should be processed by `run` call:
180
- - after the `run` callback is completed, there must be `newItems.length` elements in the DOM between backward and forward padding elements;
181
- - old items that are not in the new item list should be removed from DOM; use `oldItems[].element` references for this purpose;
182
- - 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;
183
- - 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;
184
- - 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; this requirement can be changed by the `Routines` class setting, see below;
185
- - new items elements should have "data-sid" attribute, which value should reflect `newItems[].$index`.
179
+ There are some requirements on how the items should be processed by `run` call.
180
+
181
+ - After the `run` callback is completed, there must be `newItems.length` elements in the DOM between backward and forward padding elements.
182
+ - Old items that are not in the new items list should be removed from DOM. Use `oldItems[].element` references for this purpose.
183
+ - Old items that are in the new items list should not be removed and recreated, as this may result in unwanted scroll position shifts. Just don't touch them.
184
+ - New items elements should be rendered in the correct order. Specifically, 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. The scroller maintains `$index` internally, so you only need to properly inject a set of `newItems[].element` into the DOM.
185
+ - New elements should be rendered without being visible, and this should be achieved by "fixed" positioning and "left"/"top" coordinates that take the item element out of view. The Workflow will take care of visibility after calculations. An additional `newItems[].invisible` attribute can be used to determine whether a given element should be hidden. This requirement can be changed by the `Routines` class setting (see below).
186
+ - New items elements should have a "data-sid" attribute whose value should reflect `newItems[].$index`.
186
187
 
187
188
  ### 5. Routines
188
189
 
@@ -194,7 +195,7 @@ import { Routines, Workflow } from 'vscroll';
194
195
  class CustomRoutines extends Routines { ... }
195
196
 
196
197
  new Workflow({
197
- // consumer, element, datasource, run,
198
+ consumer, element, datasource, run, // required params
198
199
  Routines: CustomRoutines
199
200
  })
200
201
  ```
@@ -213,9 +214,9 @@ If we have a table layout case where we need to specify the offset of the table
213
214
 
214
215
  ```js
215
216
  new Workflow({
216
- // consumer, element, datasource, run,
217
+ consumer, element, datasource, run, // required params
217
218
  Routines: class extends Routines {
218
- getOffset(element) {
219
+ getOffset() {
219
220
  return document.querySelector('#viewport thead')?.offsetHeight || 0;
220
221
  }
221
222
  }
@@ -292,4 +293,4 @@ VScroll will receive its own Adapter API documentation later, but for now please
292
293
 
293
294
  __________
294
295
 
295
- 2023 &copy; [Denis Hilt](https://github.com/dhilt)
296
+ 2025 &copy; [Denis Hilt](https://github.com/dhilt)
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * vscroll (https://github.com/dhilt/vscroll) FESM5
3
- * Version: 1.6.1 (2024-03-03T11:48:52.952Z)
3
+ * Version: 1.6.3 (2025-04-20T17:47:08.479Z)
4
4
  * Author: Denis Hilt
5
5
  * License: MIT
6
6
  */
@@ -377,7 +377,7 @@ var reactiveConfigStorage = new Map();
377
377
 
378
378
  var core = {
379
379
  name: 'vscroll',
380
- version: '1.6.1'
380
+ version: '1.6.3'
381
381
  };
382
382
 
383
383
  var getBox = function (id) {
@@ -1121,6 +1121,7 @@ var AdapterPrependParams;
1121
1121
  AdapterPrependParams["items"] = "items";
1122
1122
  AdapterPrependParams["bof"] = "bof";
1123
1123
  AdapterPrependParams["increase"] = "increase";
1124
+ AdapterPrependParams["virtualize"] = "virtualize";
1124
1125
  })(AdapterPrependParams || (AdapterPrependParams = {}));
1125
1126
  var PREPEND_METHOD_PARAMS = (_c = {},
1126
1127
  _c[AdapterPrependParams.items] = {
@@ -1128,19 +1129,24 @@ var PREPEND_METHOD_PARAMS = (_c = {},
1128
1129
  mandatory: true
1129
1130
  },
1130
1131
  _c[AdapterPrependParams.bof] = {
1131
- validators: [BOOLEAN],
1132
+ validators: [BOOLEAN, ONE_OF_CAN([AdapterPrependParams.virtualize])],
1132
1133
  defaultValue: false
1133
1134
  },
1134
1135
  _c[AdapterPrependParams.increase] = {
1135
1136
  validators: [BOOLEAN],
1136
1137
  defaultValue: false
1137
1138
  },
1139
+ _c[AdapterPrependParams.virtualize] = {
1140
+ validators: [BOOLEAN, ONE_OF_CAN([AdapterPrependParams.bof])],
1141
+ defaultValue: false
1142
+ },
1138
1143
  _c);
1139
1144
  var AdapterAppendParams;
1140
1145
  (function (AdapterAppendParams) {
1141
1146
  AdapterAppendParams["items"] = "items";
1142
1147
  AdapterAppendParams["eof"] = "eof";
1143
1148
  AdapterAppendParams["decrease"] = "decrease";
1149
+ AdapterAppendParams["virtualize"] = "virtualize";
1144
1150
  })(AdapterAppendParams || (AdapterAppendParams = {}));
1145
1151
  var APPEND_METHOD_PARAMS = (_d = {},
1146
1152
  _d[AdapterAppendParams.items] = {
@@ -1148,13 +1154,17 @@ var APPEND_METHOD_PARAMS = (_d = {},
1148
1154
  mandatory: true
1149
1155
  },
1150
1156
  _d[AdapterAppendParams.eof] = {
1151
- validators: [BOOLEAN],
1157
+ validators: [BOOLEAN, ONE_OF_CAN([AdapterAppendParams.virtualize])],
1152
1158
  defaultValue: false
1153
1159
  },
1154
1160
  _d[AdapterAppendParams.decrease] = {
1155
1161
  validators: [BOOLEAN],
1156
1162
  defaultValue: false
1157
1163
  },
1164
+ _d[AdapterPrependParams.virtualize] = {
1165
+ validators: [BOOLEAN, ONE_OF_CAN([AdapterAppendParams.eof])],
1166
+ defaultValue: false
1167
+ },
1158
1168
  _d);
1159
1169
  var AdapterRemoveParams;
1160
1170
  (function (AdapterRemoveParams) {
@@ -1796,7 +1806,7 @@ var Insert = /** @class */ (function (_super) {
1796
1806
  Insert.insertInBuffer = function (scroller, params) {
1797
1807
  var before = params.before, after = params.after, beforeIndex = params.beforeIndex, afterIndex = params.afterIndex, items = params.items, decrease = params.decrease;
1798
1808
  var indexToInsert = scroller.buffer.getIndexToInsert(before || after, beforeIndex, afterIndex);
1799
- if (isNaN(indexToInsert)) {
1809
+ if (params.virtualize || isNaN(indexToInsert)) {
1800
1810
  return false;
1801
1811
  }
1802
1812
  var isBackward = Number.isInteger(beforeIndex) || before;
@@ -1865,7 +1875,8 @@ var Append = /** @class */ (function (_super) {
1865
1875
  items: items,
1866
1876
  beforeIndex: beforeIndex,
1867
1877
  afterIndex: afterIndex,
1868
- decrease: opposite
1878
+ decrease: opposite,
1879
+ virtualize: params.virtualize
1869
1880
  });
1870
1881
  };
1871
1882
  return Append;