@@ -18,35 +18,39 @@ export default function ({
18
18
} ,
19
19
20
20
methods : {
21
- refreshScrollToInspected : debounce ( function ( ) {
22
- requestAnimationFrame ( ( ) => {
23
- if ( this . inspectedIndex ) this . scrollIntoInspected ( this . inspectedIndex )
24
- } )
25
- } , 200 , {
26
- leading : true
27
- } ) ,
21
+ refreshScrollToInspected ( ) {
22
+ if ( this . inspectedIndex ) this . scrollIntoInspected ( this . inspectedIndex )
23
+ } ,
28
24
29
- scrollIntoInspected : debounce ( function ( index ) {
25
+ scrollIntoInspected : debounce ( async function ( index ) {
30
26
index += indexOffset
31
- this . $nextTick ( ( ) => {
32
- const scroller = this . $globalRefs . leftRecycleList || this . $globalRefs . leftScroll
33
- if ( ! scroller ) {
34
- this . scrollIntoInspected ( index )
35
- return
36
- }
37
- const parentHeight = scroller . offsetHeight
38
- const height = this . highDensity ? 22 : 34
39
- const top = index * height
40
- const scrollTop = scroller . scrollTop
41
- if ( top < scrollTop ) {
42
- scroller . scrollTop = top
43
- } else if ( top + height > scrollTop + parentHeight ) {
44
- scroller . scrollTop = top + height - parentHeight
45
- }
46
- } )
27
+ // Wait for defer frames (time-slicing)
28
+ for ( let f = 0 ; f < 2 ; f ++ ) {
29
+ await waitForFrame ( )
30
+ }
31
+ const scroller = this . $globalRefs . leftRecycleList || this . $globalRefs . leftScroll
32
+ if ( ! scroller ) {
33
+ this . scrollIntoInspected ( index )
34
+ return
35
+ }
36
+ const parentHeight = scroller . offsetHeight
37
+ const height = this . highDensity ? 22 : 34
38
+ const top = index * height
39
+ const scrollTop = scroller . scrollTop
40
+ if ( top < scrollTop ) {
41
+ scroller . scrollTop = top
42
+ } else if ( top + height > scrollTop + parentHeight ) {
43
+ scroller . scrollTop = top + height - parentHeight
44
+ }
47
45
} , 200 , {
48
46
leading : true
49
47
} )
50
48
}
51
49
}
52
50
}
51
+
52
+ function waitForFrame ( ) {
53
+ return new Promise ( resolve => {
54
+ requestAnimationFrame ( resolve )
55
+ } )
56
+ }
0 commit comments