Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling scrollTo multiple times with animation causes the scroll to overshoot and get out of sync #222

Closed
CapsAdmin opened this issue Jul 15, 2022 · 5 comments
Assignees
Labels
bug Something isn't working needs review The issue has been solved, Wait for confirmation.

Comments

@CapsAdmin
Copy link

I'm using Carousel and some buttons calling carousel.scrollTo({index, animated: true}) to manually go to a specific item in the carousel.

If I press a button to scroll to a specific index while it's already animating to some other index, the container view seems to go out of sync. It's fixed if I manually scroll the view again with my fingers.

@CapsAdmin CapsAdmin added the bug Something isn't working label Jul 15, 2022
@CapsAdmin
Copy link
Author

A workaround I found just now is doing this instead:

carousel.scrollTo({
	count: index - carousel.getCurrentIndex(),
	animated: true,
})

as opposed to just using the index field

@oliverloops
Copy link
Collaborator

Hi @CapsAdmin, In the API count is used to move with a specific fixed parameter. index value is also used as first scroll action and overrides count direct parameter. And is possible to know how you are changing the state of index values?

@wqcstrong
Copy link

Any solution? I met the same issue, and it is not related to passed count or index

@CapsAdmin
Copy link
Author

CapsAdmin commented Jul 29, 2022

Hi @CapsAdmin, In the API count is used to move with a specific fixed parameter. index value is also used as first scroll action and overrides count direct parameter. And is possible to know how you are changing the state of index values?

I think I understand the differences, but the problem seems to be using index while it's already animating.

This looks suspicious

const offset = handlerOffsetX.value + (index.value - i) * size;

Maybe it should be using currentFixedPage() as prev and next above uses?

@dohooo dohooo added the needs review The issue has been solved, Wait for confirmation. label Aug 12, 2022
@dohooo
Copy link
Owner

dohooo commented Aug 12, 2022

Thx for your issue. fixed in v3.0.4.

@dohooo dohooo closed this as completed Aug 12, 2022
dohooo added a commit that referenced this issue Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs review The issue has been solved, Wait for confirmation.
Projects
None yet
Development

No branches or pull requests

4 participants