Skip to content

Commit

Permalink
wrap the callback in requestAnimationFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahLardeau committed Dec 3, 2021
1 parent 6099542 commit aa122d9
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/components/DynamicScroller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,24 @@ export default {
provide () {
if (typeof ResizeObserver !== 'undefined') {
this.$_resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
if (entry.target) {
const event = new CustomEvent(
'resize',
{
detail: {
contentRect: entry.contentRect,
window.requestAnimationFrame(() => {
if (!Array.isArray(entries) || !entries.length) {
return
}
for (const entry of entries) {
if (entry.target) {
const event = new CustomEvent(
'resize',
{
detail: {
contentRect: entry.contentRect,
},
},
},
)
entry.target.dispatchEvent(event)
)
entry.target.dispatchEvent(event)
}
}
}
});
})
}
Expand Down

0 comments on commit aa122d9

Please sign in to comment.