Embla Carousel v2.9.1 Release Notes

Release Date: 2020-04-21 // almost 4 years ago
  • ๐Ÿฑ ๐ŸŒŸ New features

    ๐Ÿš€ This release comes with more tools to manipulate the carousels scrollProgress.

    โž• Additions to scrollProgress

    It's now possible to get the scroll progress of either the carousels current scroll location or its target scroll location. Get the scroll progress of the carousels current scroll location:

    embla.scrollProgress()
    

    Get the scroll progress of the carousels target scroll location

    const target = trueembla.scrollProgress(target)
    

    โž• Additions to scrollBy

    It's now possible to pass a second boolean parameter if you want the carousel to snap to the closest snap position. Passing true will snap the carousel while false will scroll by the exact given amount.

    const snapToClosest = trueembla.scrollBy(0.2, snapToClosest)
    

    ๐Ÿ†• New feature scrollToProgress

    As discussed in issue #26 this feature allows for setting the absolute scroll progress directly as compared to scrollBy which adds to the current scroll progress. Like scrollBy, it also accepts a second boolean parameter if you want the carousel to snap to the closest snap position. Passing true will snap the carousel while false will scroll to the exact given progress.

    const snapToClosest = trueembla.scrollToProgress(0.2, snapToClosest)
    

    Thanks a bunch @xiel for this feature request.

    ๐Ÿฑ Enjoy ๐ŸŽ‰!