-
-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: beforeUnmount destroys too soon during Vue transitions #869
Comments
@sambedingfield thanks for your bug report. Is this expected behaviour for Or is it a bug? It seems like some of the comments suggest it's by design? This was the PR where the I'm not a seasoned Vue dev by any means but would re-introducing |
It doesn't look like it's going to change, so... by design ¯\_(ツ)_/¯ To clarify, both |
Will create Vue SFC playground to see differences between Vue versions IIRC they refactored Transition component alot lately |
@davidjerleke I'd be concerned about making such a change without extensive testing, especially given any potential errors or performance changes #672 (comment). @sambedingfield Is it possible for you to share a minimal reproduction of the problem you're experiencing so that we can visualize it, debug it, and possibly find a solution? One option I can think of is to use the embla-carousel core without the wrapper and manually destroy it whenever you want. It's actually quite simple, as demonstrated by the Vue 2 example I provided earlier. |
Here the Vue SFC playground It appears that there are issues with Transition and onBeforeUnmount |
@meirroth My CodeSandbox is in the original report, here: https://codesandbox.io/p/devbox/reverent-almeida-nh8pkr |
@sambedingfield Sorry I missed it 🤦♂️ Thanks for sharing. It seems to me that the issue persists after replacing |
@davidjerleke Just a thought, do you think this can be fixed by leaving translations as is on destroy? |
@meirroth it can, but not every user would want that. I'm not sure how to solve this in an optimal way. Maybe we can add a parameter to function destroy(keepStyles: boolean): void {
// ...
} On the other hand, that wouldn't solve this request which is related to this to some extent: |
https://stackblitz.com/edit/basic-embla-carousel-dthb3k
https://svelte.dev/repl/0e18b50b771c496dbf11a7d330a46164?version=3.31.2 |
@sadeghbarati @sambedingfield @meirroth I'm closing this issue for now if you don't have any objections? My understanding is that this problem has been raised in the |
No objections from me. Thanks for raising the problem with Vue! To conclude from my perspective, I ended up using Embla Core wrapped in a Vue component as suggested. Site launched this week actually! |
@sambedingfield nice work 👍🏻! Feel free to share it here: |
@sambedingfield Stunning website! Bookmarked. Is it plain Vue? |
Anyone who hasn’t done so yet, if you don’t mind, please go to the vuejs/core issue that @sadeghbarati created and give it a thumbs up. That would better out chances of getting it fixed: |
Which variants of Embla Carousel are you using?
Steps to reproduce
The bug occurs when I transition away a Vue component containing an Embla carousel, causing it to be destroyed too early. This causes a flicker of an unstyled carousel during the transition.
For a common example, imagine a transition on an app route and clicking a link from within a carousel slide.
The user sees the destroyed state of the carousel before the page transitions away.
Expected Behavior
That either the clean up can be prevented or delayed during
beforeUnmount
.Additional Context
To clarify, this is a known Vue thing, and not unique to Embla. It happens with a lot of libraries that clean up using Vue's
beforeUnmount
hook.A solution could be using a mutation observer or providing a timeout prop to delay the destroying.
Here's how it got discussed for Splide.
This could require a similar solution to the React issue here #540, where "freezing" styles could work.
I tried the following workaround, but it doesn't consider slides that are translated during loops :
What browsers are you seeing the problem on?
All browsers
Version
v8.0.4
CodeSandbox
https://codesandbox.io/p/devbox/reverent-almeida-nh8pkr
Before submitting
The text was updated successfully, but these errors were encountered: