Skip to content

Commit 6f359ab

Browse files
okhvrOlha KhavroAkryum
authored
fix: wrap the callback in requestAnimationFrame, fix #516 (#517)
Co-authored-by: Olha Khavro <[email protected]> Co-authored-by: Guillaume Chau <[email protected]>
1 parent f9124aa commit 6f359ab

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/components/DynamicScroller.vue

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,24 @@ export default {
5050
provide () {
5151
if (typeof ResizeObserver !== 'undefined') {
5252
this.$_resizeObserver = new ResizeObserver(entries => {
53-
for (const entry of entries) {
54-
if (entry.target) {
55-
const event = new CustomEvent(
56-
'resize',
57-
{
58-
detail: {
59-
contentRect: entry.contentRect,
53+
requestAnimationFrame(() => {
54+
if (!Array.isArray(entries)) {
55+
return
56+
}
57+
for (const entry of entries) {
58+
if (entry.target) {
59+
const event = new CustomEvent(
60+
'resize',
61+
{
62+
detail: {
63+
contentRect: entry.contentRect,
64+
},
6065
},
61-
},
62-
)
63-
entry.target.dispatchEvent(event)
66+
)
67+
entry.target.dispatchEvent(event)
68+
}
6469
}
65-
}
70+
})
6671
})
6772
}
6873

0 commit comments

Comments
 (0)