Perfect-scrollbar: How to reset the scrollbar

Created on 24 May 2015  路  1Comment  路  Source: mdbootstrap/perfect-scrollbar

I have same div which dynamically loads content. How can I reset the scrollbar every time content is loaded, so new content always starts from the top, not where the last scrollbar position was?

I tried destroy / initialize on each reload, but scrollbar stays where he was previously left?

Most helpful comment

You can just set the scrollTop to 0 and the update.

// jQuery
$container.scrollTop(0);
$container.perfectScrollbar('update');

// vanilla JS
container.scrollTop = 0;
Ps.update(container);

>All comments

You can just set the scrollTop to 0 and the update.

// jQuery
$container.scrollTop(0);
$container.perfectScrollbar('update');

// vanilla JS
container.scrollTop = 0;
Ps.update(container);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

DevTony picture DevTony  路  3Comments

Gurkirat2210 picture Gurkirat2210  路  5Comments

hatashiro picture hatashiro  路  4Comments

hyperknot picture hyperknot  路  7Comments

corysimmons picture corysimmons  路  6Comments