fix: exceeded effect on Photos page?

This commit is contained in:
2024-11-12 15:12:06 +01:00
parent 54682c6886
commit ac3070b0b7

View File

@@ -197,12 +197,13 @@
// Workaround: Reactive photos based on data // Workaround: Reactive photos based on data
$effect(() => { $effect(() => {
if (data.photos && data.photos !== photos) { if (data.photos) {
photos = data.photos photos = data.photos
} }
}) })
$effect(() => {
onMount(() => {
/** /**
* Observers * Observers
*/ */
@@ -237,17 +238,6 @@
const existingPhotos = photosGridEl.querySelectorAll('.photo') const existingPhotos = photosGridEl.querySelectorAll('.photo')
existingPhotos.forEach(el => observerPhotos.observe(el)) existingPhotos.forEach(el => observerPhotos.observe(el))
// Destroy
return () => {
// Disconnect observers
observerPhotos && observerPhotos.disconnect()
mutationPhotos && mutationPhotos.disconnect()
}
})
onMount(() => {
/** /**
* Animations * Animations
*/ */
@@ -271,6 +261,13 @@
// Run animation // Run animation
requestAnimationFrame(animation.play) requestAnimationFrame(animation.play)
// Destroy
return () => {
// Disconnect observers
observerPhotos && observerPhotos.disconnect()
mutationPhotos && mutationPhotos.disconnect()
}
}) })
</script> </script>