From b8abb0284d61e7e12cbe67ed68e4c5d31d7c07be Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Sun, 23 Sep 2018 15:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9AiP?= =?UTF-8?q?honeX=E6=A8=AA=E5=B1=8F=E6=97=B6=EF=BC=8C=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E6=A0=8F=E4=BD=BF=E7=94=A8=E5=8E=9F=E7=94=9F=E6=80=81=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8=E5=90=91?= =?UTF-8?q?=E4=B8=8B=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/wwwroot/js/common-scripts.js | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Bootstrap.Admin/wwwroot/js/common-scripts.js b/Bootstrap.Admin/wwwroot/js/common-scripts.js index cb5dbf75..1e943d2e 100644 --- a/Bootstrap.Admin/wwwroot/js/common-scripts.js +++ b/Bootstrap.Admin/wwwroot/js/common-scripts.js @@ -153,16 +153,26 @@ $(function () { $.fn.extend({ autoScrollSidebar: function (options) { - if (!this.hasClass('mCustomScrollbar')) return; var option = $.extend({ target: null, offsetTop: 0 }, options); var $navItem = option.target; - if ($navItem === null) return; + if ($navItem === null) return this; // sidebar scroll animate var middle = this.outerHeight() / 2; - var top = $navItem.offset().top - $('header').outerHeight() + option.offsetTop; - if (top > middle) this.mCustomScrollbar('scrollTo', top - middle); - + var top = 0; + 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; }, addNiceScroll: function () { @@ -183,13 +193,17 @@ $(function () { var $sidebar = $('aside').addNiceScroll().autoScrollSidebar({ target: arch.parent(), offsetTop: arch.parent().innerHeight() / 2 }); $sideMenu.on('click', 'a.dcjq-parent', function () { + var $this = $(this); if (!$.browser.versions.ios && $(window).width() > 768) { - var $this = $(this); setTimeout(function () { var offsetScroll = parseInt($this.parents('.mCSB_container').css('top').replace('px', '')); $sidebar.autoScrollSidebar({ target: $this.parent(), offsetTop: 25.5 - offsetScroll }); }, 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 () {