[Feat]: Support defining an offset value to the scrollTo
method
#934
Replies: 1 comment 1 reply
-
Just as a follow up, I was able to achieve my desired behavior using the internal engine, although I would like to avoid that in the future, if possible. const { scrollTarget, scrollTo } = api.internalEngine();
const { distance } = scrollTarget.byIndex(tabIndex, 1);
const offset = tabIndex > 0 ? 38 : 0;
scrollTo.distance(distance + offset, false); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which variants of Embla Carousel are relevant to this feature request?
Feature description
When using the
scrollTo
method to scroll to a specific index, it would be lovely if we could also provide an optional offset value so that the item isn't fully aligned to the edge of the container.Additional Context
For one of our implementations of the carousel (a carousel of tabs), the next and previous buttons sit on top of the tab bar. When we want to scroll programmatically to a specific tab, it aligns the tab all the way to the left edge, which means part of the tab is now covered by the previous button. Instead, it would be beneficial if we could scroll to a specific index and offset it by the width of the button, so it is not obscured.
Before submitting
Beta Was this translation helpful? Give feedback.
All reactions