1
+ < app-demo [datasource] ="datasource " [context] ="demoContext " [sources] ="sources ">
2
+ < div actions style ="display: flex ">
3
+ < button (click) ="doClip() "> Clip</ button >
4
+ </ div >
5
+
6
+ < div description >
7
+ < p >
8
+ < em > Adapter.clip</ em > is another < em > Adapter</ em > API method
9
+ allowing to remove out-of-viewport items on demand.
10
+ Commonly, the < em > uiScroll</ em > runs the clipping procedure
11
+ each time new items are fetched after scrolling.
12
+ Also, the < em > uiScroll</ em > clipps old items from a side of the viewport
13
+ that is opposite to a side where new items appear.
14
+ This is one of the core parts of the virtualization concept.
15
+ By invoking the < em > Adapter.clip</ em > method
16
+ we are telling the < em > uiScroll</ em > to run this process immediately
17
+ and remove items that are out of the visible part of the viewport
18
+ in both directions or in specific direction.
19
+ </ p >
20
+ < p >
21
+ This could be useful when we enlarge the list of items manually,
22
+ via < em > Adapter.append</ em > or < em > .prepend</ em > methods.
23
+ For example, we appended 100 new items and started scrolling down, in forward direction.
24
+ We might want the items that exit the viewport in backward direction to be clipped.
25
+ Such a clipping will occur automatically only when we reach the bottom line of the buffer
26
+ and new items are fetched and rendered in forward direction.
27
+ If we don't want to wait, we just call < em > Adapter.clip</ em > .
28
+ </ p >
29
+ < p >
30
+ This demo implements some artificial but quite illustrative case.
31
+ Here we disabled virtualization by turning on the < em > infinite</ em > setting.
32
+ Clipping will never happen automatically.
33
+ We see how the DOM elements counter value is getting bigger and bigger as we scroll on and on.
34
+ By pressiing the "Clip" button, we let only 20-21 items to survive.
35
+ This way a kind of manual virtualization could be implemented.
36
+ </ p >
37
+ < p >
38
+ The method has an argument object that allows to run clipping process
39
+ only in one direction:
40
+ </ p >
41
+ < pre > {{clipOptionsDescription}}</ pre >
42
+ < p >
43
+ So, if we call < em > Adapter.clip({{clipOptionsSample}})</ em > ,
44
+ only ithose tems that are out of the bottom border of the visible part of the viewport
45
+ will be clipped out.
46
+ </ p >
47
+ </ div >
48
+ </ app-demo >
0 commit comments