Fade
This plugin replaces Embla Carousel's default scrolling behavior with smooth fade transitions between slides.
Example
Installation
Start by installing the npm package and save it to your dependencies:
<script src="https://unpkg.com/embla-carousel-fade/embla-carousel-fade.umd.js"></script>npm install embla-carousel-fade --savepnpm add embla-carousel-fadeyarn add embla-carousel-fadeWhen the Fade plugin is enabled, the
inViewThreshold option no longer has
any effect. This is because the Fade plugin stacks any slides with an
opacity higher than 0 on top of each other, eliminating the concept of
scrolling and gradual appearance of slides.
If your slides are less than 100% of the viewport width, it's recommended to set these options when using the Fade plugin to avoid confusing UX:
const options = { align: 'center', containScroll: false}However, align: center is default so you can omit setting the align option and achieve the same thing like so:
const options = { containScroll: false}Options
Below follows an exhaustive list of all Fade options and their default values.
active
booleantrue{ active: false | true }Setting this to false will not activate or deactivate the plugin. Useful when used together with the breakpoints option to toggle the plugin active/inactive depending on media queries.
breakpoints
FadeOptionsType{}{ active: true, '(min-width: 768px)': { active: false }}An object with options that will be applied for a given breakpoint by overriding the options at the root level.
Note: If multiple queries match, they will be merged. And when breakpoint options clash, the last one in the list has precedence.