Comments (9)
Thanks for the quick reply !
And sorry for the late reply.
I'm just a beginner in the field of web development so I probably cannot go around writing generic use case modular wrappers but I can provide some insight on how it weirdly got fixed:
I went through the docs again and noticed the position: relative
css on .embla__slide
elements.
Even though I've set the loop property of embla to false, I needed the position: relative
to make it work.
Weird interaction I must say, plus the fact that it magically does work if the window is resized.
Anyhoo, I'll close the issue, good luck with getting a vue wrapper going, I'm sure many would benefit from it.
from embla-carousel.
Hello @xoumi,
Thank you for opening this issue π.
It's a bit hard to troubleshoot without any code at hand, but I'm guessing that it has something to do with when:
EmblaCarousel(elementNode, options);
...is called π€. It could have something to do with how front-end frameworks/libraries abstract the vanilla JavaScript away (in this case Vue) and offer component lifecycle methods instead, like a mount hook when a component has mounted. Maybe you need to hook on to a mounted()
method or similar before initialising Embla? I don't think this is an issue related to Vue itself, but I may be wrong.
For example, to make Embla compatible with React, I had to build a tiny wrapper-component. It utilises React component methods and enables React users to use Embla in their projects.
Now I know you're using Vue, so my point being is that we may need to build a Vue wrapper component to make Embla compatible with Vue. I'd be very happy if this issue leads to me being able to add a link to the Embla Carousel Vue package here π:
Unfortunately I'm not so familiar with Vue so I'd be very happy if someone could help me out with this. Maybe the Vue Flickity package code can be used as inspiration?
What do you think, does this make sense?
from embla-carousel.
Hi again @xoumi,
I've setup a working CodeSandbox example for you. It works on initialisation and doesn't need a resize in order to work correctly.
Try it out if you like π!
Just a disclaimer: I write code in Vanilla JS and React on a daily basis so I don't feel comfy with Vue. I can't guarantee that the example I've setup for you follows any Vue best practices π .
from embla-carousel.
Building a Vue wrapper for Embla issue has been opened here #17.
from embla-carousel.
Hi @xoumi,
Just wanted to let you know that a Vue 3 Embla package is available now.
Read more here.
Cheers,
David
from embla-carousel.
having the same issue on NextJS13. Adding position: relative
to .embla__slide
didn't work to me :(
from embla-carousel.
@vinisooo what version of Embla are you using?
from embla-carousel.
Hello @davidjerleke !
The problem has already been solved.
I discovered that it was happening due to the animation I put on the page:
@keyframes page-show-up
from
opacity: 0
transform: scale(0.8)
to
opacity: 1
transform: translateY(0) scale(1)
For some reason, the transforrm: scale
was breaking the carousel CSS, until I refreshed the page or resized it. So I kinda radically solved it by removing the animation.
by the way, these are the versions I am currently using:
"embla-carousel-autoplay": "^8.0.0-rc07",
"embla-carousel-react": "^8.0.0-rc07",
from embla-carousel.
Hi @vinisooo,
Thatβs happening because transform scale alters element dimensions. And upon initialization, Embla has to read container and slide dimensions in order to calculate scroll positions correctly. If you want to apply scale on your slides you will have to wait until Embla has initialized.
Best,
David
from embla-carousel.
Related Issues (20)
- [Bug]: First slide is lagging when using infinite scroll and slides with initial value of null HOT 2
- [Bug]: Synced tabs doesn't always restore scroll position when selected tab changes
- [Bug]: export the types HOT 2
- [Bug]: UI issues when removing slides HOT 6
- [Bug]: embla-carousel-autoplay - stopOnMouseEnter NOT WORKING on mouse enter, but only when you click inside the wrapper. HOT 4
- [Bug]: Event Hooks Do Not Get Called With Next 12 + React 18 HOT 5
- [Bug]: Animation doesn't work when updating options with `reInit` HOT 7
- [Bug]: Changing axis direction breaks carousel HOT 9
- [Bug]: Autoplay and AutoScroll not destroyed properly
- [Bug]: When the direction is set to 'rtl' and the loop is set to true, it doesn't loop infinitely HOT 1
- [Bug]: canScrollNext method returns false even when there are items to scroll HOT 1
- [Bug]: AutoScroll position jumps when clicked and dragged HOT 7
- [Bug]: Input click block after dragging HOT 2
- [Feat]: Add TypeScript moduleResolution: bundler support HOT 11
- [Bug]: Autplay stops working after drag HOT 2
- [Bug]: Cannot find module 'embla-carousel/components/Options' or its corresponding type declarations. TypeScript, React with Vite HOT 2
- [Bug]: Flickering when adding icon or image in slides (8.0) HOT 3
- [Bug]: Direction rtl reverses y axis direction HOT 5
- [Bug]: Slide hanging if overdragged/scrolled HOT 3
- [Bug]: Angular autoplay error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embla-carousel.