dieulot / instantclick

InstantClick makes following links in your website instant.
instantclick.io
MIT License
5.51k stars 246 forks source link

Instant Click loading bar width calculations are based off page width plus width of scrollbar #161

Open wpgbrown opened 6 years ago

wpgbrown commented 6 years ago

I am using the minified version of instant click version 3.1.0 (current)

I have a page that uses a fixed navbar and content that is not fixed, but when the instant click loading bar is created, it uses innerWidth instead of clientHeight. This causes on my page the width of the element to be more than the current page width, as it includes the width of the scrollbar. This seems to work in normal cases, but in my case this causes the page to have problems with horizontal scrollbars (and coupled with the moving of the scrollbar, moves the instant click loading bar to the left, it causes more problems).

My suggestion would be to either use clientWidth if the doctype is set (as it is inaccurate if it is not set) and then use innerWidth when it is not or to have a configuration option when initialised to use clientWidth instead of innerWidth.

Thanks, Wpgbrown

wpgbrown commented 6 years ago

I have done some tests and have concluded that using document.documentElement.clientWidth is better than innerWidth