feat: 完善侧边栏选中项自动居中动画效果功能
This commit is contained in:
parent
2f2d55bcf4
commit
890b16887a
|
@ -145,19 +145,11 @@ $(function () {
|
|||
|
||||
// sidebar scroll animate
|
||||
var middle = this.outerHeight() / 2;
|
||||
var top = 0;
|
||||
if (this.hasClass('mCustomScrollbar')) {
|
||||
top = $navItem.offset().top - $('header').outerHeight() + option.offsetTop;
|
||||
var top = $navItem.offset().top + option.offsetTop - this.offset().top;
|
||||
var $scrollInstance = this[0]["__overlayScrollbars__"];
|
||||
if (top > middle) {
|
||||
this.mCustomScrollbar('scrollTo', top - middle);
|
||||
}
|
||||
}
|
||||
else {
|
||||
top = $navItem.offset().top + option.offsetTop;
|
||||
if (top > middle)
|
||||
this.animate({
|
||||
scrollTop: top - middle
|
||||
});
|
||||
if ($scrollInstance) $scrollInstance.scroll({ x: 0, y: top - middle }, 500, "swing");
|
||||
else this.animate({ scrollTop: top - middle });
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue