Adjust for scrolling off-by-one errors
On some pages with particular zoom levels, elem.offsetHeight is exactly one pixel more than elem.scrollHeight when fully scrolled down. This is probably due to rounding/floats/off-by-one errors somewhere inside Chromium? We now instead always clip the displayed percentage at 100% (so we don't display 101%), and consider the page fully scrolled even if we're scrolled more than the page.
This commit is contained in:
parent
fc0b62f122
commit
bd831939bc
@ -258,11 +258,18 @@ class WebEngineScroller(browsertab.AbstractScroller):
|
||||
self._pos_px = QPoint(jsret['px']['x'], jsret['px']['y'])
|
||||
|
||||
dx = jsret['scroll']['width'] - jsret['inner']['width']
|
||||
perc_x = 0 if dx == 0 else round(100 / dx * jsret['px']['x'])
|
||||
dy = jsret['scroll']['height'] - jsret['inner']['height']
|
||||
perc_y = 0 if dy == 0 else round(100 / dy * jsret['px']['y'])
|
||||
if dx == 0:
|
||||
perc_x = 0
|
||||
else:
|
||||
perc_x = min(100, round(100 / dx * jsret['px']['x']))
|
||||
|
||||
self._at_bottom = dy == jsret['px']['y']
|
||||
dy = jsret['scroll']['height'] - jsret['inner']['height']
|
||||
if dy == 0:
|
||||
perc_y = 0
|
||||
else:
|
||||
perc_y = min(100, round(100 / dy * jsret['px']['y']))
|
||||
|
||||
self._at_bottom = dy >= jsret['px']['y']
|
||||
self._pos_perc = perc_x, perc_y
|
||||
|
||||
self.perc_changed.emit(*self._pos_perc)
|
||||
|
Loading…
Reference in New Issue
Block a user