vscroll 1.4.0 → 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.
- package/LICENSE +1 -1
- package/README.md +17 -16
- package/dist/bundles/vscroll.esm5.js +367 -286
- package/dist/bundles/vscroll.esm5.js.map +1 -1
- package/dist/bundles/vscroll.esm5.min.js +2 -2
- package/dist/bundles/vscroll.esm5.min.js.map +1 -1
- package/dist/bundles/vscroll.esm6.js +325 -244
- package/dist/bundles/vscroll.esm6.js.map +1 -1
- package/dist/bundles/vscroll.esm6.min.js +2 -2
- package/dist/bundles/vscroll.esm6.min.js.map +1 -1
- package/dist/bundles/vscroll.umd.js +370 -289
- package/dist/bundles/vscroll.umd.js.map +1 -1
- package/dist/bundles/vscroll.umd.min.js +2 -2
- package/dist/bundles/vscroll.umd.min.js.map +1 -1
- package/dist/esm2015/classes/buffer/checkCall.js.map +1 -1
- package/dist/esm2015/classes/domRoutines.js +110 -41
- package/dist/esm2015/classes/domRoutines.js.map +1 -1
- package/dist/esm2015/classes/item.js +4 -0
- package/dist/esm2015/classes/item.js.map +1 -1
- package/dist/esm2015/classes/logger.js +2 -2
- package/dist/esm2015/classes/logger.js.map +1 -1
- package/dist/esm2015/classes/paddings.js +7 -5
- package/dist/esm2015/classes/paddings.js.map +1 -1
- package/dist/esm2015/classes/state/cycle.js +7 -6
- package/dist/esm2015/classes/state/cycle.js.map +1 -1
- package/dist/esm2015/classes/state/render.js +1 -1
- package/dist/esm2015/classes/state/render.js.map +1 -1
- package/dist/esm2015/classes/state/scroll.js +6 -6
- package/dist/esm2015/classes/state/scroll.js.map +1 -1
- package/dist/esm2015/classes/state.js +23 -15
- package/dist/esm2015/classes/state.js.map +1 -1
- package/dist/esm2015/classes/viewport.js +15 -44
- package/dist/esm2015/classes/viewport.js.map +1 -1
- package/dist/esm2015/interfaces/index.js.map +1 -1
- package/dist/esm2015/interfaces/routines.js +2 -0
- package/dist/esm2015/interfaces/routines.js.map +1 -0
- package/dist/esm2015/interfaces/state.js.map +1 -1
- package/dist/esm2015/processes/adapter/reload.js +1 -1
- package/dist/esm2015/processes/adapter/reload.js.map +1 -1
- package/dist/esm2015/processes/adjust.js +44 -15
- package/dist/esm2015/processes/adjust.js.map +1 -1
- package/dist/esm2015/processes/end.js +18 -16
- package/dist/esm2015/processes/end.js.map +1 -1
- package/dist/esm2015/processes/fetch.js +3 -3
- package/dist/esm2015/processes/fetch.js.map +1 -1
- package/dist/esm2015/processes/init.js +2 -2
- package/dist/esm2015/processes/init.js.map +1 -1
- package/dist/esm2015/processes/render.js +8 -11
- package/dist/esm2015/processes/render.js.map +1 -1
- package/dist/esm2015/processes/scroll.js +21 -21
- package/dist/esm2015/processes/scroll.js.map +1 -1
- package/dist/esm2015/scroller.js +3 -3
- package/dist/esm2015/scroller.js.map +1 -1
- package/dist/esm2015/version.js +1 -1
- package/dist/esm2015/version.js.map +1 -1
- package/dist/esm2015/workflow.js +5 -6
- package/dist/esm2015/workflow.js.map +1 -1
- package/dist/esm5/classes/buffer/checkCall.js.map +1 -1
- package/dist/esm5/classes/buffer/defaultSize.js +1 -1
- package/dist/esm5/classes/buffer/defaultSize.js.map +1 -1
- package/dist/esm5/classes/buffer.js +7 -7
- package/dist/esm5/classes/buffer.js.map +1 -1
- package/dist/esm5/classes/domRoutines.js +113 -41
- package/dist/esm5/classes/domRoutines.js.map +1 -1
- package/dist/esm5/classes/item.js +4 -0
- package/dist/esm5/classes/item.js.map +1 -1
- package/dist/esm5/classes/logger.js +7 -7
- package/dist/esm5/classes/logger.js.map +1 -1
- package/dist/esm5/classes/paddings.js +7 -5
- package/dist/esm5/classes/paddings.js.map +1 -1
- package/dist/esm5/classes/state/cycle.js +7 -6
- package/dist/esm5/classes/state/cycle.js.map +1 -1
- package/dist/esm5/classes/state/render.js +1 -1
- package/dist/esm5/classes/state/render.js.map +1 -1
- package/dist/esm5/classes/state/scroll.js +11 -11
- package/dist/esm5/classes/state/scroll.js.map +1 -1
- package/dist/esm5/classes/state.js +23 -15
- package/dist/esm5/classes/state.js.map +1 -1
- package/dist/esm5/classes/viewport.js +16 -46
- package/dist/esm5/classes/viewport.js.map +1 -1
- package/dist/esm5/inputs/validation.js +2 -2
- package/dist/esm5/inputs/validation.js.map +1 -1
- package/dist/esm5/interfaces/index.js.map +1 -1
- package/dist/esm5/interfaces/routines.js +2 -0
- package/dist/esm5/interfaces/routines.js.map +1 -0
- package/dist/esm5/interfaces/state.js.map +1 -1
- package/dist/esm5/processes/adapter/append.js +1 -1
- package/dist/esm5/processes/adapter/append.js.map +1 -1
- package/dist/esm5/processes/adapter/fix.js +1 -1
- package/dist/esm5/processes/adapter/fix.js.map +1 -1
- package/dist/esm5/processes/adapter/insert.js +1 -1
- package/dist/esm5/processes/adapter/insert.js.map +1 -1
- package/dist/esm5/processes/adapter/reload.js +1 -1
- package/dist/esm5/processes/adapter/reload.js.map +1 -1
- package/dist/esm5/processes/adapter/remove.js +1 -1
- package/dist/esm5/processes/adapter/remove.js.map +1 -1
- package/dist/esm5/processes/adjust.js +44 -15
- package/dist/esm5/processes/adjust.js.map +1 -1
- package/dist/esm5/processes/end.js +18 -16
- package/dist/esm5/processes/end.js.map +1 -1
- package/dist/esm5/processes/fetch.js +3 -3
- package/dist/esm5/processes/fetch.js.map +1 -1
- package/dist/esm5/processes/init.js +2 -2
- package/dist/esm5/processes/init.js.map +1 -1
- package/dist/esm5/processes/preFetch.js +1 -1
- package/dist/esm5/processes/preFetch.js.map +1 -1
- package/dist/esm5/processes/render.js +8 -11
- package/dist/esm5/processes/render.js.map +1 -1
- package/dist/esm5/processes/scroll.js +21 -21
- package/dist/esm5/processes/scroll.js.map +1 -1
- package/dist/esm5/scroller.js +3 -3
- package/dist/esm5/scroller.js.map +1 -1
- package/dist/esm5/version.js +1 -1
- package/dist/esm5/version.js.map +1 -1
- package/dist/esm5/workflow.js +10 -13
- package/dist/esm5/workflow.js.map +1 -1
- package/dist/typings/classes/domRoutines.d.ts +25 -11
- package/dist/typings/classes/item.d.ts +1 -0
- package/dist/typings/classes/logger.d.ts +1 -1
- package/dist/typings/classes/paddings.d.ts +2 -2
- package/dist/typings/classes/state/cycle.d.ts +1 -1
- package/dist/typings/classes/state/render.d.ts +1 -1
- package/dist/typings/classes/state/scroll.d.ts +4 -4
- package/dist/typings/classes/state.d.ts +6 -3
- package/dist/typings/classes/viewport.d.ts +3 -6
- package/dist/typings/interfaces/index.d.ts +3 -2
- package/dist/typings/interfaces/routines.d.ts +154 -0
- package/dist/typings/interfaces/state.d.ts +2 -15
- package/dist/typings/processes/adjust.d.ts +1 -0
- package/dist/typings/processes/end.d.ts +1 -2
- package/dist/typings/workflow.d.ts +1 -1
- package/package.json +17 -17
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
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:
|
|
144
|
-
// assume
|
|
145
|
-
if (!
|
|
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
|
-
|
|
149
|
-
|
|
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
|
|
166
|
-
- after the `run
|
|
167
|
-
|
|
168
|
-
- old items that are in the list should
|
|
169
|
-
- new items elements should be rendered in accordance with `
|
|
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 `
|
|
171
|
-
- new items elements should have "data-sid" attribute, which value should reflect `
|
|
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.
|
|
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
|
-
|
|
227
|
+
2022 © [Denis Hilt](https://github.com/dhilt)
|