增加功能:iPhoneX横屏时,侧边栏使用原生态滚动条支持自动向下滚动
This commit is contained in:
parent
abdf2a5977
commit
b8abb0284d
|
@ -153,16 +153,26 @@ $(function () {
|
||||||
|
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
autoScrollSidebar: function (options) {
|
autoScrollSidebar: function (options) {
|
||||||
if (!this.hasClass('mCustomScrollbar')) return;
|
|
||||||
var option = $.extend({ target: null, offsetTop: 0 }, options);
|
var option = $.extend({ target: null, offsetTop: 0 }, options);
|
||||||
var $navItem = option.target;
|
var $navItem = option.target;
|
||||||
if ($navItem === null) return;
|
if ($navItem === null) return this;
|
||||||
|
|
||||||
// sidebar scroll animate
|
// sidebar scroll animate
|
||||||
var middle = this.outerHeight() / 2;
|
var middle = this.outerHeight() / 2;
|
||||||
var top = $navItem.offset().top - $('header').outerHeight() + option.offsetTop;
|
var top = 0;
|
||||||
if (top > middle) this.mCustomScrollbar('scrollTo', top - middle);
|
if (this.hasClass('mCustomScrollbar')) {
|
||||||
|
top = $navItem.offset().top - $('header').outerHeight() + option.offsetTop;
|
||||||
|
if (top > middle) {
|
||||||
|
this.mCustomScrollbar('scrollTo', top - middle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
top = $navItem.offset().top + option.offsetTop;
|
||||||
|
if (top > middle)
|
||||||
|
this.animate({
|
||||||
|
scrollTop: top - middle
|
||||||
|
});
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
addNiceScroll: function () {
|
addNiceScroll: function () {
|
||||||
|
@ -183,13 +193,17 @@ $(function () {
|
||||||
var $sidebar = $('aside').addNiceScroll().autoScrollSidebar({ target: arch.parent(), offsetTop: arch.parent().innerHeight() / 2 });
|
var $sidebar = $('aside').addNiceScroll().autoScrollSidebar({ target: arch.parent(), offsetTop: arch.parent().innerHeight() / 2 });
|
||||||
|
|
||||||
$sideMenu.on('click', 'a.dcjq-parent', function () {
|
$sideMenu.on('click', 'a.dcjq-parent', function () {
|
||||||
|
var $this = $(this);
|
||||||
if (!$.browser.versions.ios && $(window).width() > 768) {
|
if (!$.browser.versions.ios && $(window).width() > 768) {
|
||||||
var $this = $(this);
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
var offsetScroll = parseInt($this.parents('.mCSB_container').css('top').replace('px', ''));
|
var offsetScroll = parseInt($this.parents('.mCSB_container').css('top').replace('px', ''));
|
||||||
$sidebar.autoScrollSidebar({ target: $this.parent(), offsetTop: 25.5 - offsetScroll });
|
$sidebar.autoScrollSidebar({ target: $this.parent(), offsetTop: 25.5 - offsetScroll });
|
||||||
}, 600);
|
}, 600);
|
||||||
}
|
}
|
||||||
|
else if ($.browser.versions.ios && $(window).width() > 768) {
|
||||||
|
var offsetScroll = parseInt($this.parents('aside').scrollTop());
|
||||||
|
$sidebar.autoScrollSidebar({ target: $this.parent(), offsetTop: 25.5 + offsetScroll });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.sidebar-toggle-box').on('click', function () {
|
$('.sidebar-toggle-box').on('click', function () {
|
||||||
|
|
Loading…
Reference in New Issue