Closed csalinezh closed 4 months ago
A quick fix would be changing that lower bound to tabList.scrollWidth - 1
. That might be just enough to work around this rounding issue.
Thank you for your insight! The fractional pixel issues have been my bane of existence for a long time and this is super helpful in various issues plaguing TabberNeue regarding fractional pixels. I will be releasing a patch later and hopefully it will address all of the related issues.
Currently https://github.com/StarCitizenTools/mediawiki-extensions-TabberNeue/blob/cfe539df906890c511d145ab68d2cc52bb50f661/modules/ext.tabberNeue.legacy/ext.tabberNeue.legacy.js#L183 checks whether the navigation tab has been scrolled to the right end by comparing
tabList.scrollLeft + tabList.offsetWidth
andtabList.scrollWidth
. This is straightforward and appears to be a common practice.However the logic fails for me (Chrome 124.0.6367.60) due to some rounding issue. The respective values when I have scrolled to the right end are 20.571428298950195, 984 and 1005. It leads to a small cosmetic issue (the next arrow never disappears).
MDN says that scrollWidth will be rounded to integer, which is probably the cause. The document says
getBoundingClientRect()
can be used to obtain accurate values, however I'm not able to figure out how to getscrollWidth
from it. It indeed shows a fractionalwidth
of this element (984.071533203125).