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

When scrolling with offset, page jumps to zero offset when animation is complete #30

Closed
joshuatuscan opened this issue May 29, 2018 · 6 comments

Comments

@joshuatuscan
Copy link

joshuatuscan commented May 29, 2018

I'm using Scrollchor with no child anchor and have the offset set to -170. After the animation completes, when the hash URL updates, the page scrolls to 0 offset for the element. Seems like maybe the event doesn't have preventDefault set.

@joshuatuscan
Copy link
Author

I believe this was the result of default hash behavior conflicting with the component animation. I used the disableHistory prop and it solved my problem of not jumping to 0 offset. If you use history and update the hashes, it still jumps however.

@joshuatuscan joshuatuscan reopened this May 29, 2018
@gitjul
Copy link

gitjul commented Jun 4, 2018

I'm experiencing the same issue.

@bySabi
Copy link
Collaborator

bySabi commented Jun 4, 2018

The problem is on: updateHistory function and the intended behavior of window.location.hash that can't be changed even with event.preventDefault, see this thread: https://stackoverflow.com/questions/3870057/how-can-i-update-window-location-hash-without-jumping-the-document

In order of prevent jump and still use history the user must handle back button by itself.

We can follow two possible paths:

  • add a prefix parameter to updateHistory or
  • make updateHistory a callback, then the user can pass the implementation that he prefer.

Another idea?... What will be desirable?

@bySabi
Copy link
Collaborator

bySabi commented Jun 4, 2018

It solved on new release, 5.1.0.

Please update your code and tell me is ok.

Thanks for report the issue.

@bySabi bySabi closed this as completed Jun 4, 2018
@joshuatuscan
Copy link
Author

Seems to be working great. Thanks for the update!

@gitjul
Copy link

gitjul commented Jun 4, 2018

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants