2
2
<div class =" app-container" >
3
3
<div class =" list-container" >
4
4
<div class =" title" >VirtualisedList</div >
5
+ <div >
6
+ <button @click =" scrollListToStart" >Scroll To Start</button >
7
+ <button @click =" scrollListToEnd" >Scroll To End</button >
8
+ <button @click =" scrollListToIndex" >Scroll To Index</button >
9
+ <input v-model =" listIndex" type =" number" min =" 0" />
10
+ <button @click =" scrollListToHeight" >Scroll To Height</button >
11
+ <input v-model =" listHeight" type =" number" min =" 0" />
12
+ </div >
5
13
<virtualised-list
14
+ ref =" listView"
6
15
:nodes =" data"
7
16
:viewport-height =" viewportHeight"
8
17
:initial-scroll-top =" initialScrollTop"
20
29
</div >
21
30
<div class =" tree-container" >
22
31
<div class =" title" >VirtualisedTree</div >
32
+ <div >
33
+ <button @click =" scrollTreeToStart" >Scroll To Start</button >
34
+ <button @click =" scrollTreeToEnd" >Scroll To End</button >
35
+ <button @click =" scrollTreeToIndex" >Scroll To Index</button >
36
+ <input v-model =" treeIndex" type =" number" min =" 0" />
37
+ <button @click =" scrollTreeToHeight" >Scroll To Height</button >
38
+ <input v-model =" treeHeight" type =" number" min =" 0" />
39
+ <button @click =" forceUpdate" >Force Refresh</button >
40
+ </div >
23
41
<virtualised-tree
24
42
ref =" treeView"
25
43
:nodes =" nodes"
@@ -60,8 +78,19 @@ export default defineComponent({
60
78
VirtualisedTree ,
61
79
},
62
80
setup() {
81
+ const listView = ref <typeof VirtualisedList | null >(null );
63
82
const treeView = ref <typeof VirtualisedTree | null >(null );
64
83
84
+ const listIndex = ref <number >(0 );
85
+ const listHeight = ref <number >(0 );
86
+
87
+ const scrollListToStart = () => listView .value ?.scrollToStart ();
88
+ const scrollListToEnd = () => listView .value ?.scrollToEnd ();
89
+ const scrollListToIndex = () =>
90
+ listView .value ?.scrollToIndex (listIndex .value );
91
+ const scrollListToHeight = () =>
92
+ listView .value ?.scrollToHeight (listHeight .value );
93
+
65
94
const nodes = constructFixedTree (6 , 15 , 5 );
66
95
67
96
const onChange = (nodes : Array <Node | NodeModel >) =>
@@ -71,6 +100,18 @@ export default defineComponent({
71
100
h (" div" , { class: " cell-container list-cell-container" }, node .label ),
72
101
];
73
102
103
+ const treeIndex = ref <number >(0 );
104
+ const treeHeight = ref <number >(0 );
105
+
106
+ const scrollTreeToStart = () => treeView .value ?.scrollToStart ();
107
+ const scrollTreeToEnd = () => treeView .value ?.scrollToEnd ();
108
+ const scrollTreeToIndex = () =>
109
+ treeView .value ?.scrollToIndex (treeIndex .value );
110
+ const scrollTreeToHeight = () =>
111
+ treeView .value ?.scrollToHeight (treeHeight .value );
112
+
113
+ const forceUpdate = async () => await treeView .value ?.forceUpdate ();
114
+
74
115
const treeCellRenderer = (node : NodeModel , index : number ) => [
75
116
h (
76
117
" div" ,
@@ -175,11 +216,25 @@ export default defineComponent({
175
216
};
176
217
177
218
return {
219
+ listView ,
178
220
treeView ,
221
+ listIndex ,
222
+ listHeight ,
223
+ scrollListToStart ,
224
+ scrollListToEnd ,
225
+ scrollListToIndex ,
226
+ scrollListToHeight ,
179
227
nodes ,
180
228
onChange ,
181
229
listCellRenderer ,
182
230
treeCellRenderer ,
231
+ treeIndex ,
232
+ treeHeight ,
233
+ scrollTreeToStart ,
234
+ scrollTreeToEnd ,
235
+ scrollTreeToIndex ,
236
+ scrollTreeToHeight ,
237
+ forceUpdate ,
183
238
handleScroll ,
184
239
handleStartReached ,
185
240
handleEndReached ,
0 commit comments