Simplebar: Scroll to Top

Created on 1 May 2017  路  6Comments  路  Source: Grsmto/simplebar

setting up some data tables using jquery ui tabs , setting fixed height and using your scrollbar, question is on each tab click , can this scroll bar be reset to top of the div or table , currently on tab click the next tabs content is scrolled down to where previous tabs content was being used

Most helpful comment

When i console el.SimpleBar am getting undefined.Can any one help me?

Code:
var el = new SimpleBar(document.getElementById('myElement'));
console.log(el.SimpleBar); //undefined

All 6 comments

Yes it's possible doing something like this:

var el = new SimpleBar(document.getElementById('myElement'));
el.SimpleBar.getScrollElement().scrollTop = 0;

When i console el.SimpleBar am getting undefined.Can any one help me?

Code:
var el = new SimpleBar(document.getElementById('myElement'));
console.log(el.SimpleBar); //undefined

For anyone, who stumbles upon this in future. el.SimpleBar is not defined anymore. el is the SimpleBar element. So use it like this:
el.getScrollElement().scrollTop = 0;

<div id="listing-container" data-simplebar data-simplebar-auto-hide="false">
    <div>data here</div>
</div>
function scrollIt() {
  const scrollElement = 
  document.getElementById('listingcontainer').SimpleBar.getScrollElement();
  scrollElement.scrollTop = 1200;
}

I'm getting el.getScrollElement() == undefined

I'm getting el.getScrollElement() == undefined

Me too, any help?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Blackleones picture Blackleones  路  3Comments

bennymeg picture bennymeg  路  3Comments

EmilMoe picture EmilMoe  路  4Comments

ghost picture ghost  路  4Comments

idiotWu picture idiotWu  路  3Comments