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.
- package/LICENSE +1 -1
- package/README.md +105 -58
- package/dist/bundles/vscroll.esm5.js +204 -176
- 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 +122 -112
- 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 +205 -177
- 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.js +2 -6
- package/dist/esm2015/classes/buffer.js.map +1 -1
- package/dist/esm2015/classes/domRoutines.js +93 -69
- package/dist/esm2015/classes/domRoutines.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 +5 -5
- package/dist/esm2015/classes/paddings.js.map +1 -1
- package/dist/esm2015/classes/viewport.js +9 -21
- package/dist/esm2015/classes/viewport.js.map +1 -1
- package/dist/esm2015/index.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/workflow.js.map +1 -1
- package/dist/esm2015/scroller.js +4 -4
- 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 +6 -4
- package/dist/esm2015/workflow.js.map +1 -1
- package/dist/esm5/classes/adapter.js +4 -4
- package/dist/esm5/classes/adapter.js.map +1 -1
- package/dist/esm5/classes/buffer/cache.js +1 -1
- package/dist/esm5/classes/buffer/cache.js.map +1 -1
- package/dist/esm5/classes/buffer/checkCall.js +4 -4
- package/dist/esm5/classes/buffer/checkCall.js.map +1 -1
- package/dist/esm5/classes/buffer.js +5 -9
- package/dist/esm5/classes/buffer.js.map +1 -1
- package/dist/esm5/classes/domRoutines.js +107 -69
- package/dist/esm5/classes/domRoutines.js.map +1 -1
- package/dist/esm5/classes/logger.js +21 -21
- package/dist/esm5/classes/logger.js.map +1 -1
- package/dist/esm5/classes/paddings.js +5 -5
- package/dist/esm5/classes/paddings.js.map +1 -1
- package/dist/esm5/classes/state/cycle.js +2 -2
- package/dist/esm5/classes/state/cycle.js.map +1 -1
- package/dist/esm5/classes/viewport.js +10 -22
- package/dist/esm5/classes/viewport.js.map +1 -1
- package/dist/esm5/index.js.map +1 -1
- package/dist/esm5/inputs/validation.js +4 -4
- 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/workflow.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 +5 -5
- package/dist/esm5/processes/adjust.js.map +1 -1
- package/dist/esm5/processes/clip.js +5 -5
- package/dist/esm5/processes/clip.js.map +1 -1
- package/dist/esm5/processes/fetch.js +2 -2
- package/dist/esm5/processes/fetch.js.map +1 -1
- package/dist/esm5/processes/misc/base.js +1 -1
- package/dist/esm5/processes/misc/base.js.map +1 -1
- package/dist/esm5/processes/preClip.js +2 -2
- package/dist/esm5/processes/preClip.js.map +1 -1
- package/dist/esm5/processes/preFetch.js +5 -5
- package/dist/esm5/processes/preFetch.js.map +1 -1
- package/dist/esm5/processes/scroll.js +2 -2
- package/dist/esm5/processes/scroll.js.map +1 -1
- package/dist/esm5/scroller.js +5 -5
- 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 +12 -6
- package/dist/esm5/workflow.js.map +1 -1
- package/dist/typings/classes/domRoutines.d.ts +21 -19
- package/dist/typings/classes/logger.d.ts +1 -1
- package/dist/typings/classes/paddings.d.ts +2 -2
- package/dist/typings/classes/viewport.d.ts +1 -4
- package/dist/typings/index.d.ts +2 -2
- package/dist/typings/interfaces/index.d.ts +2 -1
- package/dist/typings/interfaces/routines.d.ts +157 -0
- package/dist/typings/interfaces/workflow.d.ts +3 -0
- package/dist/typings/scroller.d.ts +1 -1
- package/dist/typings/workflow.d.ts +1 -1
- package/package.json +18 -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
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
# VScroll
|
|
5
5
|
|
|
6
|
+
- [Overview](#overview)
|
|
7
|
+
- [Getting started](#getting-started)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Consumer](#1-consumer)
|
|
10
|
+
- [Element](#2-element)
|
|
11
|
+
- [Datasource](#3-datasource)
|
|
12
|
+
- [Run](#4-run)
|
|
13
|
+
- [Routines](#5-routines)
|
|
14
|
+
- [Live](#live)
|
|
15
|
+
- [Adapter API](#adapter-api)
|
|
16
|
+
- [Thanks](#thanks)
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
6
20
|
VScroll is a JavaScript library providing virtual scroll engine. Can be seen as a core for platform-specific solutions designed to represent unlimited datasets using virtualization technique. Below is the diagram of how the VScroll engine is being distributed to the end user.
|
|
7
21
|
|
|
8
22
|
<br>
|
|
@@ -10,10 +24,11 @@ VScroll is a JavaScript library providing virtual scroll engine. Can be seen as
|
|
|
10
24
|
<img src="https://user-images.githubusercontent.com/4365660/104845671-ad1d4b80-58e7-11eb-9cc9-4a00ebcbc9e8.png">
|
|
11
25
|
</p>
|
|
12
26
|
|
|
13
|
-
Basically, the consumer layer can be omitted and the end Application developers can use VScroll directly.
|
|
27
|
+
Basically, the consumer layer can be omitted and the end Application developers can use VScroll directly. This repository has a [minimal demo page](https://dhilt.github.io/vscroll/) of direct use of the VScroll library in a non-specific environment. There are also several consumer implementations built on top of VScroll:
|
|
14
28
|
|
|
15
29
|
- [ngx-ui-scroll](https://github.com/dhilt/ngx-ui-scroll), Angular virtual scroll directive
|
|
16
30
|
- [vscroll-native](https://github.com/dhilt/vscroll-native), virtual scroll module for native JavaScript applications
|
|
31
|
+
- [Vue integration sample](https://stackblitz.com/edit/vscroll-vue-integration?file=src%2Fcomponents%2FVScroll.vue), very rough implementation for Vue
|
|
17
32
|
|
|
18
33
|
## Getting started
|
|
19
34
|
|
|
@@ -22,7 +37,7 @@ Basically, the consumer layer can be omitted and the end Application developers
|
|
|
22
37
|
```html
|
|
23
38
|
<script src="https://cdn.jsdelivr.net/npm/vscroll"></script>
|
|
24
39
|
<script>
|
|
25
|
-
const workflow = new VScroll.Workflow(
|
|
40
|
+
const workflow = new VScroll.Workflow(...);
|
|
26
41
|
</script>
|
|
27
42
|
```
|
|
28
43
|
|
|
@@ -35,12 +50,18 @@ npm install vscroll
|
|
|
35
50
|
```js
|
|
36
51
|
import { Workflow } from 'vscroll';
|
|
37
52
|
|
|
38
|
-
const workflow = new Workflow(
|
|
53
|
+
const workflow = new Workflow(...);
|
|
39
54
|
```
|
|
40
55
|
|
|
41
56
|
## Usage
|
|
42
57
|
|
|
43
|
-
The main entity distributed via `vscroll` is the `Workflow` class. Its instantiating runs the virtual scroll engine.
|
|
58
|
+
The main entity distributed via `vscroll` is the `Workflow` class. Its instantiating runs the virtual scroll engine.
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
new Workflow({ consumer, element, datasource, run });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The constructor of the `Workflow` class requires an argument of the following type:
|
|
44
65
|
|
|
45
66
|
```typescript
|
|
46
67
|
interface WorkflowParams<ItemData> {
|
|
@@ -48,6 +69,7 @@ interface WorkflowParams<ItemData> {
|
|
|
48
69
|
element: HTMLElement;
|
|
49
70
|
datasource: IDatasource<ItemData>;
|
|
50
71
|
run: OnDataChanged<ItemData>;
|
|
72
|
+
Routines?: CustomRoutinesClass;
|
|
51
73
|
}
|
|
52
74
|
```
|
|
53
75
|
|
|
@@ -58,10 +80,10 @@ This is a TypeScript definition, but speaking of JavaScript, an argument object
|
|
|
58
80
|
A simple data object that provides information about a consumer. It is not critical to omit this, but if the result solution is going to be published as a separate 3d-party library ("consumer"), the name and the version of the result package should be passed as follows:
|
|
59
81
|
|
|
60
82
|
```js
|
|
61
|
-
consumer
|
|
83
|
+
const consumer = {
|
|
62
84
|
name: 'my-vscroll-consumer',
|
|
63
85
|
version: 'v1.0.0-alpha.1'
|
|
64
|
-
}
|
|
86
|
+
};
|
|
65
87
|
```
|
|
66
88
|
|
|
67
89
|
### 2. Element
|
|
@@ -69,7 +91,7 @@ consumer: {
|
|
|
69
91
|
An HTML element the `Workflow` should use as a scrollable part of the viewport. It should be present in DOM before instantiating the `Workflow`.
|
|
70
92
|
|
|
71
93
|
```js
|
|
72
|
-
element
|
|
94
|
+
const element = document.getElementById('vscroll');
|
|
73
95
|
```
|
|
74
96
|
|
|
75
97
|
This element should be wrapped with another container with constrained height and overflow scroll/auto. And it also must have two special padding elements marked with special attributes for the virtualization purpose.
|
|
@@ -92,93 +114,116 @@ This element should be wrapped with another container with constrained height an
|
|
|
92
114
|
|
|
93
115
|
### 3. Datasource
|
|
94
116
|
|
|
95
|
-
This is a special object, providing dataset items in runtime.
|
|
117
|
+
This is a special object, providing dataset items in runtime. There is a separate wiki document describing the Datasource: [github.com/dhilt/vscroll/wiki/Datasource](https://github.com/dhilt/vscroll/wiki/Datasource). Below is a short version.
|
|
118
|
+
|
|
119
|
+
The Datasource can be defined in two ways. First, as an object literal:
|
|
96
120
|
|
|
97
121
|
```js
|
|
98
|
-
datasource
|
|
122
|
+
const datasource = {
|
|
99
123
|
get: (index, count, success) => {
|
|
100
124
|
const data = [];
|
|
101
|
-
for (let i = index; i
|
|
125
|
+
for (let i = index; i < index + count; i++) {
|
|
102
126
|
data.push({ id: i, text: 'item #' + i });
|
|
103
127
|
}
|
|
104
128
|
success(data);
|
|
105
129
|
}
|
|
106
|
-
}
|
|
130
|
+
};
|
|
107
131
|
```
|
|
108
132
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Along with the `Workflow`, VScroll exposes method `makeDatasource` which can be used for creating Datasource factory, so the end Datasource might be instantiated via operator `new`:
|
|
133
|
+
Second, as an instance of Datasource class which can be obtained through a special factory method. Along with the `Workflow` class, VScroll exposes the `makeDatasource` method which can be used for creating Datasource class, so the end datasource object can be instantiated via operator `new`:
|
|
112
134
|
|
|
113
135
|
```js
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
136
|
+
import { makeDatasource } from 'vscroll';
|
|
137
|
+
const Datasource = makeDatasource();
|
|
138
|
+
|
|
139
|
+
const datasource = new Datasource({
|
|
140
|
+
get: (index, length, success) =>
|
|
141
|
+
success(Array.from({ length }).map((_, i) =>
|
|
142
|
+
({ id: index + i, text: 'item #' + (index + i) })
|
|
143
|
+
))
|
|
144
|
+
});
|
|
119
145
|
```
|
|
120
146
|
|
|
121
|
-
|
|
147
|
+
The argument of the Datasource class is the same object literal as in the first case. It has one mandatory field which is the core of the App-Scroller integration: method `get`. The `Workflow` requests data via the `Datasource.get` method in runtime.
|
|
122
148
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```typescript
|
|
126
|
-
interface Data {
|
|
127
|
-
id: number;
|
|
128
|
-
text: string;
|
|
129
|
-
...
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const Datasource = VScroll.makeDatasource();
|
|
133
|
-
const datasource = new Datasource<Data>(...);
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
This obliges the Datasource.get method to deal with _Data_ items and also provides strong typing for Adapter API props and methods.
|
|
149
|
+
For more solid understanding the concept of the Datasource with examples, please, refer to [the Datasource doc](https://github.com/dhilt/vscroll/wiki/Datasource).
|
|
137
150
|
|
|
138
151
|
### 4. Run
|
|
139
152
|
|
|
140
153
|
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
154
|
|
|
142
155
|
```js
|
|
143
|
-
run:
|
|
144
|
-
// assume
|
|
145
|
-
if (!
|
|
156
|
+
run: (newItems) => {
|
|
157
|
+
// assume oldItems contains a list of items that are currently present in the UI
|
|
158
|
+
if (!newItems.length && !oldItems.length) {
|
|
146
159
|
return;
|
|
147
160
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
// make newItems to be present in the UI instead of oldItems
|
|
162
|
+
processItems(newItems, oldItems);
|
|
163
|
+
oldItems = newItems;
|
|
164
|
+
};
|
|
151
165
|
```
|
|
152
166
|
|
|
153
|
-
Each item is an instance of the [Item class](https://github.com/dhilt/vscroll/blob/v1.
|
|
167
|
+
Each item (in both `newItems` and `oldItems` lists) is an instance of the [Item class](https://github.com/dhilt/vscroll/blob/v1.5.0/src/classes/item.ts) implementing the [Item interface](https://github.com/dhilt/vscroll/blob/v1.5.0/src/interfaces/item.ts), whose props can be used for proper implementation of the `run` callback:
|
|
154
168
|
|
|
155
169
|
|Name|Type|Description|
|
|
156
170
|
|:--|:--|:----|
|
|
157
171
|
|element|_HTMLElement_|HTML element associated with the item|
|
|
158
172
|
|$index|_number_|Integer index of the item in the Datasource. Correlates with the first argument of the Datasource.get method|
|
|
159
173
|
|data|_Data_|Data (contents) of the item. This is what the Datasource.get passes to the Scroller via success-callback as an array of data-items typed as Data[]|
|
|
160
|
-
|invisible|_boolean_|
|
|
161
|
-
|get|_() => ItemAdapter<Data>_|
|
|
174
|
+
|invisible|_boolean_|Flag that determines whether the item should be hidden (if _true_) or visible (if _false_) when the _run_ method is called|
|
|
175
|
+
|get|_() => ItemAdapter<Data>_|Shortcut method returning { element, $index, data } object|
|
|
162
176
|
|
|
163
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.
|
|
164
178
|
|
|
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 `
|
|
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`.
|
|
186
|
+
|
|
187
|
+
### 5. Routines
|
|
188
|
+
|
|
189
|
+
A special class allowing to override the default behavior related to the DOM. All DOM-specific operations are implemented as the [DOM Routines class](https://github.com/dhilt/vscroll/blob/v1.5.0/src/classes/domRoutines.ts) methods inside core. When the `Routines` class setting is passed among the Workflow arguments, its methods override the base class methods. The Routines methods description can be taken from the [IRoutines interface](https://github.com/dhilt/vscroll/blob/v1.5.0/src/interfaces/routines.ts) sources. For example, there is a method that throws an error if its argument is not an HTML element:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
checkElement(element: HTMLElement): void {
|
|
193
|
+
if (!element) {
|
|
194
|
+
throw new Error('HTML element is not defined');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
With the `Routines` class setting it can be overridden as follows:
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
new Workflow({
|
|
203
|
+
consumer, element, datasource, run,
|
|
204
|
+
Routines: class {
|
|
205
|
+
checkElement(element) {
|
|
206
|
+
if (!element || typeof element.querySelector !== 'function') {
|
|
207
|
+
throw new Error('Fatal: expecting HTML element');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Various DOM calculations, setting/getting the scroll position, render process and other logic can be adjusted, improved or completely replaced by custom methods of the `Routines` class setting.
|
|
172
215
|
|
|
173
216
|
## Live
|
|
174
217
|
|
|
175
|
-
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
|
|
218
|
+
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 have 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 its [demo](https://github.com/dhilt/vscroll-native/tree/main/demo) may shed light on `vscroll` usage in no-framework environment.
|
|
176
219
|
|
|
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.
|
|
220
|
+
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.3.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
221
|
|
|
179
222
|
## Adapter API
|
|
180
223
|
|
|
181
|
-
Adapter API is a powerful feature of the `vscroll` engine
|
|
224
|
+
Adapter API is a powerful feature of the `vscroll` engine allowing to collect the statistics and provide runtime manipulations with the viewport: adding, removing, updating items. This API is very useful when building the real-time interactive applications when data can change over time by not only scrolling (like chats).
|
|
225
|
+
|
|
226
|
+
Please refer to the ngx-ui-scroll [Adapter API doc](https://github.com/dhilt/ngx-ui-scroll#adapter-api) as it can be applied to `vscroll` case with only one important difference: vscroll does not have RxJs entities, it has [Reactive](https://github.com/dhilt/vscroll/blob/main/src/classes/reactive.ts) ones instead. It means, for example, `eof$` has no "subscribe" method, but "on":
|
|
182
227
|
|
|
183
228
|
```js
|
|
184
229
|
// ngx-ui-scroll
|
|
@@ -191,16 +236,16 @@ myDatasource.adapter.bof$.on(value =>
|
|
|
191
236
|
);
|
|
192
237
|
```
|
|
193
238
|
|
|
194
|
-
Adapter API becomes available as `Datasource.adapter` property after the Datasource is instantiated via operator "new". In terms of "vscroll" you need to get a Datasource class by calling `makeDatasource` method, then you can instantiate it. `makeDatasource` accepts 1 argument, which is an Adapter custom configuration. Currently this config can only be used to redefine the just mentioned Adapter reactive props. Here's an example of how simple Reactive props can be overridden with RxJs Subject and BehaviorSubject entities: [ui-scroll.datasource.ts](https://github.com/dhilt/ngx-ui-scroll/blob/v2.
|
|
239
|
+
Adapter API becomes available as the `Datasource.adapter` property after the Datasource is instantiated via operator "new". In terms of "vscroll" you need to get a Datasource class by calling the `makeDatasource` method, then you can instantiate it. `makeDatasource` accepts 1 argument, which is an Adapter custom configuration. Currently this config can only be used to redefine the just mentioned Adapter reactive props. Here's an example of how simple Reactive props can be overridden with RxJs Subject and BehaviorSubject entities: [ui-scroll.datasource.ts](https://github.com/dhilt/ngx-ui-scroll/blob/v2.3.1/src/ui-scroll.datasource.ts).
|
|
195
240
|
|
|
196
|
-
An important note is that the Adapter getting ready breaks onto 2 parts: instantiation (which is synchronous with the Datasource instantiation) and initialization (which occurs during the Workflow instantiating). Adapter gets all necessary props and methods during the first phase, but
|
|
241
|
+
An important note is that the Adapter getting ready breaks onto 2 parts: instantiation (which is synchronous with the Datasource instantiation) and initialization (which occurs during the Workflow instantiating). Adapter gets all necessary props and methods during the first phase, but they start work only when the second phase is done. Practically this means
|
|
197
242
|
- you may arrange any Adapter reactive subscriptions in your app/consumer right after the Datasource is instantiated,
|
|
198
243
|
- some of the initial (default) values can be unusable, like `Adapter.bufferInfo.minIndex` = NaN (because Scroller's Buffer is empty before the very first `Datasource.get` call),
|
|
199
244
|
- Adapter methods do nothing when called before phase 2, they immediately resolve some default "good" value (`{ immediate: true, success: true, ... }`).
|
|
200
245
|
|
|
201
246
|
If there is some logic that could potentially run before the Adapter initialization and you don't want this to happen, the following approach can be applied:
|
|
202
247
|
|
|
203
|
-
```
|
|
248
|
+
```js
|
|
204
249
|
myDatasource = new VScroll.makeDatasource()({...});
|
|
205
250
|
myDatasource.adapter.init$.once(() => {
|
|
206
251
|
console.log('The Adapter is initialized'); // 2nd output
|
|
@@ -217,10 +262,12 @@ VScroll will receive its own Adapter API documentation later, but for now please
|
|
|
217
262
|
|
|
218
263
|
\- to [Joshua Toenyes](https://github.com/JoshuaToenyes) as he transferred ownership to the "vscroll" npm repository which he owned but did not use,
|
|
219
264
|
|
|
220
|
-
\- to all contributors of related repositories ([link](https://github.com/angular-ui/ui-scroll/graphs/contributors), [link](https://github.com/dhilt/ngx-ui-scroll/graphs/contributors))
|
|
265
|
+
\- to all contributors of related repositories ([link](https://github.com/angular-ui/ui-scroll/graphs/contributors), [link](https://github.com/dhilt/ngx-ui-scroll/graphs/contributors)),
|
|
266
|
+
|
|
267
|
+
\- to all donators as their great support does increase motivation.
|
|
221
268
|
|
|
222
269
|
<br>
|
|
223
270
|
|
|
224
271
|
__________
|
|
225
272
|
|
|
226
|
-
|
|
273
|
+
2022 © [Denis Hilt](https://github.com/dhilt)
|