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

Weird position values on text page #501

Closed
TimsManter opened this issue Jul 12, 2018 · 3 comments
Closed

Weird position values on text page #501

TimsManter opened this issue Jul 12, 2018 · 3 comments

Comments

@TimsManter
Copy link

vimb, version 3.2.0

Steps to reproduce

Go to kernel coding style and scroll down the page,

Expected behaviour

Page position indicator (at right in address bar) shoud inform about view position on the page in %s.

Actual behaviour

Values starts from about 61537% and while scrolling go to 0% then loop again from around 2^16%.

@fanglingsu
Copy link
Owner

I can confirm that the scroll indicator shows sometime wired things. For me it shows "All", which should only be displayed if the page fits into the viewport. I'm not sure how to fix this. At the time we use the webextension to calculate the required information by using the dome api. But there seems to be pages or documents (are represented as DOM in browser too) where our calculation is completely wrong.

@TimsManter
Copy link
Author

I made some tests to check why, when and where that weird values happen. I didn't get into code yet but it looks like webextension checks only document.body.scrollTop and document.body.clientHeight. While the first one works always when body element is scrolled, the second one that should return absolute height of element sometimes returns height of visible part (viewport) so scroll position can be bigger than body height and this causes overflow. The solution is to check document.documentElement.offsetHeight which returns real height value and then look for the bigger one. Stackoverflow already has formula for it here.

And some screenshots:

Inspect body on DDG body.clientHeight works on DDG On text page clientHeight of body doesn't work but documentElement.offsetHeight does! Also note that body.scrollTop is still correct
2018-07-14_14-20-54 2018-07-14_14-29-09 2018-07-14_15-13-11

Another issue as you said is it shows All string like... always when scroll is 0% whether or not body is scrollable. Of course because vimb can only scroll body frame it gets funny on sites like Reddit (after redesign) where after click on a post it's shown in overlay and j/k bindings still scroll page behind (together with position indicator) instead of just post, but it's another problem.

@fanglingsu
Copy link
Owner

@TimsManter Thank you for your detailed investigations. These information helped me a lot. I've made a new branch so we can test this a while.

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

No branches or pull requests

2 participants