studiometa / ui

📦 A set of opiniated, unstyled and accessible components
https://ui.studiometa.dev/-/
MIT License
10 stars 1 forks source link

Missing terminate emitter for figure intended? #64

Closed iuscare closed 2 years ago

iuscare commented 2 years ago

Hi there,

just ported over your wonderful figure element and played around a little bit with it. I recognized that there doesn't seem to be an unobserve call once the images have been lazy loaded, because in withMountWhenInView.js is no destroyed method defined and terminated is not being called. This leads to retriggering the mounted() function when scrolling the element(s) in view again without any effects. For a classic lazy loading functionality we might want to unobserve the element after the src has been exchanged or is this intended by design (e.g. to retrigger more advanced visual animations in both directions)? If it is intended I guess I could simply extend the figure class and call this.$emit('terminate') within the destroyed function to get the expected behavior so this question is just for clarity and maybe for a little improvement for you if this was not intended that way.

titouanmathis commented 2 years ago

Hey @iuscare,

Thanks for the report!

It seems like this could indeed be an improvement of our Figure component as it is never terminated, triggering the mounted method each time it appears but without any effect as the image is already loaded.

This behaviour is not intended, as this component only aims to lazy-load images. We have the ScrollAnimation and ScrollReveal components for advanced animation based on the scroll state.

I will add this to our to-do list for the next release.