Skip to content

Commit

Permalink
perf(QInfiniteScroll): force stop all svg animations in the "loading"…
Browse files Browse the repository at this point in the history
… slot when slot is not on screen #15094
  • Loading branch information
rstoenescu committed Jan 11, 2023
1 parent c04fde3 commit 2909bf7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ui/src/components/infinite-scroll/QInfiniteScroll.js
Expand Up @@ -171,16 +171,18 @@ export default createComponent({
}
}

// we need to pause svg animations (if any) otherwise
// the browser will keep on recalculating the style
watch(isFetching, val => {
function updateSvgAnimations (fetching) {
if (loadingRef.value !== null) {
const action = `${ val === true ? 'un' : '' }pauseAnimations`
// we need to pause svg animations (if any) when hiding
// otherwise the browser will keep on recalculating the style
const action = `${ fetching === true ? 'un' : '' }pauseAnimations`
Array.from(loadingRef.value.getElementsByTagName('svg')).forEach(el => {
el[ action ]()
})
}
})
}

watch(isFetching, updateSvgAnimations)

watch(() => props.disable, val => {
if (val === true) { stop() }
Expand Down Expand Up @@ -219,6 +221,7 @@ export default createComponent({
onMounted(() => {
setDebounce(props.debounce)
updateScrollTarget()
isFetching.value === false && updateSvgAnimations(false)
})

// expose public methods
Expand Down

0 comments on commit 2909bf7

Please sign in to comment.