aidanlister / jquery-stickytabs

Provides persistant state (back and forward button support) for Bootstrap tabs
http://aidanlister.com/2014/03/persisting-the-tab-state-in-bootstrap/
MIT License
60 stars 33 forks source link

Bootstrap v4 and backToTop option #30

Open djmtype opened 7 years ago

djmtype commented 7 years ago

Enabling backToTop abruptly jumps to the top of the page when using this plugin along with Bootstrap v4 tabs. Plus, it would be ideal to scroll to where the tabs start, and not at the very top of the page. What if the tab section is in the middle of the page?

// My current code. 
// I tried adding the scrollTo so the page would scroll instead of jump, but it fails.

$(function() {
var backToTop = function() {
  if (settings.backToTop === true) {
    window.scrollTo(0, 0);
    document.body.scrollTop;
  }
}
    var options = { 
        backToTop: true
    };
    $('.nav-tabs').stickyTabs( options );
});