Search code examples
javascripthtmlperfect-scrollbar

Perfect scrollbar continues to be displayed even after content is reduced


I am trying perfect scrollbar. The scrollbar works fine... it starts display of the scrollbar when content exceeds. ...BUT! When content is deleted to be less than the div's height, I would expect the scrollbar to go away. It does not. It goes only after the dragger is moved up or the rail above the dragger is clicked on.

To let the scrollbar go right away after the content is deleted, does this require use of the eventhandlers and be done programmatically in Javascript? I would have expected this to be a default behaviour. There is nothing much to show in code but here is how I initialize it:

  const ps = new PerfectScrollbar('#editDiv', {
                    maxScrollbarLength: 60,
                    minScrollbarLength: 30
              });

I had initially changed the CSS to alter the width of the scrollbar and change colors. Just to be sure, I reinstalled the CSS with zero changes just to check this behavior. And its still the same.

EDIT: Try with the browser's default scrollbar. The scrollbar goes as soon as the content is deleted to be less than div's height.


Solution

  • Use ps.update() if the content changes.