You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+14-11
Original file line number
Diff line number
Diff line change
@@ -229,13 +229,7 @@ exactly `count` elements unless it hit eof/bof.
229
229
230
230
* Properties `minIndex` and `maxIndex`
231
231
232
-
As the scroller receives the items requested by the `get` method, the value of minimum and maximum values of the item index are placed in the `minIndex` and `maxIndex` properties respectively. These values are used to maintain the appearance of the scrollbar. The values of the properties can be internaly changed by the ui-scroll engine in three cases:
233
-
* reset both properties in response to a call to the adapter `reload` method;
234
-
* increment `minIndex` in response to deleting the topmost element via adapter `applyUpdates` method;
235
-
* decrement `maxIndex` in response to deleting anything other than the topmost element via adapter `applyUpdates` method.
236
-
237
-
Values of the properties can be assigned programmatically. If the range of the index values is known in advance, assigning them programmatically would improve the usability of the scrollBar.
238
-
232
+
If the boundaries of the dataset are known, we may virtualize all the dataset by assigning appropriate values to `minIndex` and `maxIndex` datasource properties. This would improve the usability of the scroll bar: the uiScroll will maintain forward and backward padding elements of the viewport assuming the dataset consists of (maxIndex - minIndex) items. So it will be possible to jump to any position immediately.
239
233
240
234
### Adapter
241
235
@@ -286,21 +280,26 @@ Adapter object implements the following methods
286
280
287
281
* Method `applyUpdates`
288
282
289
-
applyUpdates(index, newItems)
283
+
applyUpdates(index, newItems, options)
290
284
291
285
Replaces the item in the buffer at the given index with the new items.
292
286
293
287
Parameters
294
288
***index** provides position of the item to be affected in the dataset (not in the buffer). If the item with the given index currently is not in the buffer no updates will be applied. `$index` property of the item $scope can be used to access the index value for a given item
295
289
***newItems** is an array of items to replace the affected item. If the array is empty (`[]`) the item will be deleted, otherwise the items in the array replace the item. If the newItem array contains the old item, the old item stays in place.
296
290
297
-
applyUpdates(updater)
291
+
applyUpdates(updater, options)
298
292
299
293
Updates scroller content as determined by the updater function
300
294
301
295
Parameters
302
296
***updater** is a function to be applied to every item currently in the buffer. The function will receive 3 parameters: `item`, `scope`, and `element`. Here `item` is the item to be affected, `scope` is the item $scope, and `element` is the html element for the item. The return value of the function should be an array of items. Similarly to the `newItem` parameter (see above), if the array is empty(`[]`), the item is deleted, otherwise the item is replaced by the items in the array. If the return value is not an array, the item remains unaffected, unless some updates were made to the item in the updater function. This can be thought of as in place update.
303
297
298
+
Options for both signatures, an object with following fields
299
+
***immutableTop** is a boolean flag with `false` defalt value. This option has an impact on removing/inserting items procedure. If it's `false`, deleting the topmost item will lead to incrementing min index, also inserting new item(s) before the topmost one will lead to decrementing min index. If it's `true`, min index will not be affected, max index will be shifted instead. If it's `true`, no matter which item is going to be removed/inserted, max index will be reduced/increased respectively.
300
+
301
+
Let's discuss a little sample. We have `{{$index}}: {{item}}` template and three rows: `1: item1`, `2: item2`, `3: item3`. Then we want to remove the first item. Without `immutableTop` we'll get `2: item2`, `3: item3`. With `immutableTop` we'll get `1: item2`, `2: item3`. The same for inserting, say, `item0` before `item1`. Without `immutableTop` we'll get `0: item0`, `1: item1`, `2: item2`, `3: item3`. With `immutableTop` we'll get `1: item0`, `2: item1`, `3: item2`, `4: item3`.
302
+
304
303
* Method `append`
305
304
306
305
append(newItems)
@@ -312,12 +311,13 @@ Adapter object implements the following methods
312
311
313
312
* Method `prepend`
314
313
315
-
prepend(newItems)
314
+
prepend(newItems, options)
316
315
317
-
Adds new items before the first item in the buffer.
316
+
Adds new items before the first item in the buffer. Works exactly as inserting new item(s) before the topmost one via `applyUpdates` method.
318
317
319
318
Parameters
320
319
***newItems** provides an array of items to be prepended.
320
+
***options** the same object as the last argument of `applyUpdates` method; `options.immutableTop` set to `true` will make min index unchangeable, max index will be increased. Otherwise (`options.immutableTop = false`, the default case), min index will be increased.
321
321
322
322
#### Manipulating the scroller content with the adapter methods
323
323
Adapter methods `applyUpdates`, `append` and `prepend` provide a way to update the scroller content without full reload of the content from the datasource. The updates are performed by changing the items in the scroller internal buffer after they are loaded from the datasource. Items in the buffer can be deleted or replaced with one or more items.
@@ -477,6 +477,9 @@ Pull Rerquest should include source code (./scr) changes, may include tests (./t
477
477
478
478
## Change log
479
479
480
+
### v1.7.6
481
+
* Added immutableTop option for applyUpdates and prepend Adapter methods.
482
+
480
483
### v1.7.5
481
484
* Added bufferFirst, bufferLast, bufferLength read-only properties to the Adapter.
0 commit comments