Dogstudio / highway

Highway - A Modern Javascript Transitions Manager
https://highway.js.org/
MIT License
1.43k stars 92 forks source link

Page jerking bug #65

Closed adm1t closed 4 years ago

adm1t commented 4 years ago

Hello everybody. I ran into the following problem when using the awesome library 'highway.js'. The pages slightly bounce when I navigate the site in any way, except by clicking on links (for example, backward / forward buttons). How can i fix this?

Anthodpnt commented 4 years ago

Hello @adm1t

That doesn't seem to be related to Highway. Highway is only injecting the DOM elements in the body and manages the browser's history. Please make sure this doesn't come from your animations or the way you are removing the old DOM from the body.

Best regards, Anthodpnt

adm1t commented 4 years ago

@Anthodpnt thank you for your comment. I have no ideas what this might be related to. May be something wrong with the page structure... I tried to delete all the animations and use transition code from docs, but the problem still remained. Besides I also found the same bug on one of the hall of fame sites - https://www.realconomy.com/

ThaoD5 commented 4 years ago

Hello @adm1t , I don't encounter any issue with the https://www.realconomy.com/ website; Highway is not managing any scroll position or animation, so like @Anthodpnt said, it is very unlikely that the issue is coming from Highway itself.

I also have to insist that without further code documentation and a live example; we are unable to provide any further help on this subject.

adm1t commented 4 years ago

@ThaoD5 Well, I reproduced an example of a site where you can observe the problem I described. Look at the link https://adm1t.github.io/highway-issue . Among other things, I even recorded a video, that's available on https://youtu.be/AQukaAwcoQ0 .

adm1t commented 4 years ago

Finally i've found the solution!! I will send a PR with a fix. 😉

tsharms commented 4 years ago

Funny, I'm the developer who has created realconomy.com and encountered the problem in an other project of mine. I was looking for a solution and came across this issue. The fix for this problem is:

document.addEventListener('DOMContentLoaded', () => {
    // Fix the page jerking.
    if ('scrollRestoration' in window.history) window.history.scrollRestoration = 'manual';
}

(Got it from your pull request) Thanks!