[Help]: Animations add incorrect slides offset, but only sometimes #346
-
Hi David! I've recently released @mantine/carousel package that uses embla under the hood. There is a minor issue – when carousel is rendered within a container that is animated on mount carousel slides get an unexpected offset (example – open modal and switch slides – https://codesandbox.io/s/reverent-sara-4bk0dg?file=/src/App.js). The issue can be fixed by calling P.S. great work on the library, I've enjoyed building the package! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Hi Vitaly (@rtivital), Thank you for your question and congratulations on your new major version 5 release. I saw your release post on Reddit and it seems like devs are saying great things about Mantine in general and the new upgraded Mantine 5.0.0 🎉! The problemI think you correctly describe why this is happening here:
...so nice catch 🙂. Embla Carousel works a bit different than other carousel libraries in the sense that it only reads slide positions and sizes (width/height) upon initialisation. If you compare with many other libraries, they set slide widths themselves and also add a lot of styling like
As goes for any piece of software, design choices have pros and cons. The pros and cons of only reading slide dimensions and not setting them:
Possible solutionsOne way to solve this when a modal is toggled open would be like this:
I didn't dive into your modal code so I don't know if this is doable for you without too much of a hassle. Another way to solve it is as you mention running If you have an alternative solution in mind, please feel free to share. On a side note
Thank you! I hope that Embla has been easy to work with and didn't cause you too much of a headache 😅. If you haven't noticed already, I would like to mention that I recently released v7 of Embla. Many people have been wanting the breakpoints option so maybe it will make your life's easier too. Read more about that and the additional features here. Let me know if this helps or not. Best, |
Beta Was this translation helpful? Give feedback.
-
Hi @rtivital, Just wanted to let you know that the mantinedev/mantine#2041 (comment) here probably won't be needed in Embla v8 if the changes in this PR don't cause any unexpected problems: Cheers, |
Beta Was this translation helpful? Give feedback.
Hi Vitaly (@rtivital),
Thank you for your question and congratulations on your new major version 5 release. I saw your release post on Reddit and it seems like devs are saying great things about Mantine in general and the new upgraded Mantine 5.0.0 🎉!
The problem
I think you correctly describe why this is happening here:
...so nice catch 🙂. Embla Carousel works a bit different than other carousel libraries in the sense that it only reads slide positions and sizes (width/height) upon initialisation. If you compare with many other libraries, they set slide widths themsel…