perfect-scrollbar
perfect-scrollbar copied to clipboard
Wheel propagation not always working for bottom or right when using zoom (at least in Chrome)
Really sorry, but I don't know how to use GitHub rules. Anyway, I found an issue and made a fix to it, and thought I would share it.
The issue is that if you set the wheel propagation option to true, the wheel event might still be "stopped" although you scrolled to the end of the element. This happens at least when site based zoom is applied (assume it to happen with element zoom as well).
The reason why it doesn't work is that the "shouldPreventDefault" check uses scrollTop + offsetHeight === scrollHeight -logic. However, scrollTop or scrollLeft is not always an integer (if zoomed). It seems that for my case (scrollTop + offsetHeight) is usually a little bit more than the rounded integer, but sometimes a little bit less. To handle all this I changed two lines (725 and 728): take a Math.ceil of the scroll value and change === to >= . Now works for me - and will also still fully scroll to the bottom or right (due to how perfect-scrollbar handles "shouldPreventDefault" after the check).
MASTER BRANCH LINES: 725: element.scrollTop + element.offsetHeight === element.scrollHeight; 728: element.scrollLeft + element.offsetWidth === element.offsetWidth;
WHEEL PROPRAGATION ZOOM FIX LINES: 725: Math.ceil(element.scrollTop) + element.offsetHeight >= element.scrollHeight; 728: Math.ceil(element.scrollLeft) + element.offsetWidth >= element.scrollWidth;
+1 to add it in next version...