]> git.gir.st - VimFx.git/commit
(half/full) page scrolling: don't take position:absolute headers into account
authorgirst <girst@users.noreply.github.com>
Tue, 29 Aug 2023 17:04:12 +0000 (19:04 +0200)
committergirst <girst@users.noreply.github.com>
Tue, 29 Aug 2023 17:04:12 +0000 (19:04 +0200)
commit7115cfbea5e2e8ce76026f88819cfb50dc806caf
treebd6bfeffc3c30b2c865752bb45d11094e2698675
parente30b58fa8a577add77e880fa8d176d7b99c7df54
(half/full) page scrolling: don't take position:absolute headers into account

Github's new code view[1] places each line of code visible on screen, as
well as some above and below, as a position:absolute element (within a
position:relative parent). Our code did not check whether such an
element is absolute w.r.t the current scrolling viewport or some other
element and would horribly miscalculate the amount to scroll: It would
take all off-screen position:absolute elements and add their heights,
then subtract that from the amount to scroll; even turning the scoll
amount negative!

Further,
* medium[.]com does not appear to use any footer any more, and
* the website mentioned in #698, inbound[.]org no longer resolves.

The referenced Firefox implementation doesn't check position:absolute
elements at all. As an actual improvement, Firefox now actually checks
for position:sticky elements, but only when they are 'stuck' (and
therefore behaving like position:fixed)[2]. They use some Gecko
internals, but this could be implemented in VimFx using something along
the lines of this:

    isStuck = (elem) => elem.getBoundingClientRect().top <= parseInt(getComputedStyle(elem).top)

1: https://github.blog/2023-06-21-crafting-a-better-faster-code-view/
2: https://hg.mozilla.org/mozilla-central/rev/263936aecc1d
extension/lib/viewport.coffee
Imprint / Impressum