Skip to content

Commit

Permalink
fix: use animation frames when nodes are added
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Sep 25, 2021
1 parent fccbb00 commit a319706
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/mrujs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ function addedNodesCallback (this: MrujsInterface, mutationList: MutationRecord[
addedNodes = Array.from(mutation.addedNodes)
}

window.mrujs.allPlugins.forEach((plugin: MrujsPluginInterface) => {
if (typeof plugin.observerCallback === 'function') {
plugin.observerCallback(addedNodes)
}
// kick it into an animation frame so we dont delay rendering
window.requestAnimationFrame(() => {
window.mrujs.allPlugins.forEach((plugin: MrujsPluginInterface) => {
if (typeof plugin.observerCallback === 'function') {
plugin.observerCallback(addedNodes)
}
})
})
}
}
Expand Down

0 comments on commit a319706

Please sign in to comment.