Perfect-scrollbar: Infinite scrolling past container when scrollbar rail has borders

Created on 11 Jul 2014  路  5Comments  路  Source: mdbootstrap/perfect-scrollbar

There's a bug if the scrollbar rail has borders: it keeps scrolling even after it reaches the end (slowly, like 1px per every keystroke/mousewheel scroll).

This applies to the right and down direction (for X and Y rail respectively).

I can replicate the behaviour on the demo site by adding the 1px borders to the rails through inspector.

I have fixed the bug by replacing lines 196-197 in perfect-scrollbar.js with this:

var railBorderXWidth = parseInt($scrollbarXRail.css('borderLeftWidth'),10) + parseInt($scrollbarXRail.css('borderRightWidth'),10);
var railBorderYWidth = parseInt($scrollbarXRail.css('borderTopWidth'),10) + parseInt($scrollbarXRail.css('borderBottomWidth'),10);

$scrollbarX.css({left: scrollbarXLeft, width: scrollbarXWidth - railBorderXWidth});
$scrollbarY.css({top: scrollbarYTop, height: scrollbarYHeight - railBorderYWidth});

Obviously there are better ways to do this, like calculating the variables once on initalisation.

Most helpful comment

Another way to fix this bug is to add box-sizing: border-box to css rule for .ps-scrollbar-y-rail and ps-scrollbar-x-rail classes. Don't forget to add border width to the scrollbar width according to the border-box model.

All 5 comments

Another way to fix this bug is to add box-sizing: border-box to css rule for .ps-scrollbar-y-rail and ps-scrollbar-x-rail classes. Don't forget to add border width to the scrollbar width according to the border-box model.

Patch merged. Thanks!

Hi! Now have the same problem

image

perfect scroll bar table keeps on scrolling up after using perfect scrolll bar . Does any one knows about fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Brugarolas picture Brugarolas  路  7Comments

costea93 picture costea93  路  6Comments

MigFerreira picture MigFerreira  路  7Comments

hatashiro picture hatashiro  路  7Comments

gpluess picture gpluess  路  4Comments