Releases: davidjerleke/embla-carousel
Releases · davidjerleke/embla-carousel
v4.1.3 - Refactor of EventEmitter
🌟 Improvements
This release comes with a refactored eventEmitter
component that slightly reduces the bundle size.
v4.1.2 - Improve ScrollBounds
🌟 Improvements
- The
ScrollBounds
component is now responsible for applying friction instead of thedragHandler
component when the carousel is out of bounds.
v4.1.1 - Migrate from TravisCI to Github Actions
v4.1.0 - RTL Support
🌟 New Features
This release comes with RTL (Right To Left) support (#43) for Embla. Special thanks to @omarkhatibco and @ppromerojr for all the help. And good news! This feature doesn't add any weight to the Embla library. It actually comes with a slightly reduced bundle size.
Usage
The options object is configured like so:
const emblaNode = document.getElementById('embla')
const options = { direction: 'rtl' } // Default is 'ltr'
const embla = EmblaCarousel(emblaNode, options)
The HTML direction also has to be set to RTL. This can be achieved by using the HTML dir attribute:
<div class="embla" id="embla" dir="rtl">
...
</div>
...or using the CSS direction property:
.embla {
direction: rtl;
}
CodeSandboxes
I've added the following two sandboxes to the examples page to get you started:
Enjoy!
v4.0.5 - Check for truthy class names before toggling them
v4.0.3 - SlidesInView & Text Selection bug
🛠️ Bugfixes
Comes with fixes for:
- Issue #87. Special thanks to @S1SYPHOS for reporting this.
- Issue #102. Special thanks to @huttameps for reporting this.
v4.0.2 - Resize debounce bugfix
v4.0.0 - An upgraded React hook
Note! This major release comes with breaking changes for React users only ⚛️!
Massive thanks to Felix (@xiel) for his contributions to this release 🙏!
🌟 Improvements
- Instead of exposing an encapsulated component
<EmblaCarouselReact>
, theuseEmblaCarousel()
hook now exposes aref
you can attach to your own component. Theref
approach makes the Embla footprint smaller regarding forcing stuff on the user. Basically, what the<EmblaCarouselReact>
component did was creating a React Element with the style{ overflow: "hidden" }
. As a consequence, the user had to pass a string to choose DOM element type (div, ul, section etc...) and had to use the className prop in order to style the encapsulated element. This release solves issue #94. - Embla Carousel didn't initialize correctly if the component that used
<EmblaCarouselReact>
returnednull
before initializing the carousel. This release solves issue #91. - The options parameter passed to the
useEmblaCarousel({ loop: false })
was before this release a one way ticket. Changing options didn't reinitialize the carousel with the new options. This has been fixed in this release.
Migration
Migrating is luckily very easy.
❌ Deprecated way to do it
import React, { useEffect } from 'react'
import { useEmblaCarousel } from 'embla-carousel/react'
const EmblaCarousel = () => {
const [EmblaCarouselReact, emblaApi] = useEmblaCarousel({ loop: false })
return (
<EmblaCarouselReact>
<div className="embla__container">
<div className="embla__slide">Slide 1</div>
<div className="embla__slide">Slide 2</div>
<div className="embla__slide">Slide 3</div>
</div>
</EmblaCarouselReact>
)
}
export default EmblaCarousel
✅ New way to do it
import React, { useEffect } from 'react'
import { useEmblaCarousel } from 'embla-carousel/react'
const EmblaCarousel = () => {
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: false })
return (
<div className="embla" ref={emblaRef}> /* Make sure this element has overflow: hidden; */
<div className="embla__container">
<div className="embla__slide">Slide 1</div>
<div className="embla__slide">Slide 2</div>
<div className="embla__slide">Slide 3</div>
</div>
</div>
)
}
export default EmblaCarousel
Enjoy!