v2.9.1 - Scroll Progress additions
🌟 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 = true
embla.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 = true
embla.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 = true
embla.scrollToProgress(0.2, snapToClosest)
Thanks a bunch @xiel for this feature request.
Enjoy 🎉!