修改BUG:有子菜单的节点点击时,自动展开到不可见区域

This commit is contained in:
Argo-Lenovo 2016-11-21 18:17:27 +08:00
parent 2e333dd7bb
commit 8e6694c021
1 changed files with 10 additions and 1 deletions

View File

@ -23,9 +23,18 @@
var top = arch.offset().top;
if (top > 0) {
var middle = $('header').outerHeight() + $sidebar.outerHeight() / 2;
if (top > middle) $sidebar.animate({ scrollTop: top + arch.outerHeight() / 2 - middle }, 800);
if (top > middle) $sidebar.animate({ scrollTop: top + arch.outerHeight() / 2 - middle }, 500);
}
$sidebar.on('click', 'a.dcjq-parent', function () {
var o = ($(this).offset());
diff = 110 - o.top;
if (diff > 0)
$sidebar.scrollTo("-=" + Math.abs(diff), 500);
else
$sidebar.scrollTo("+=" + Math.abs(diff), 500);
});
$('.sidebar-toggle-box').on('click', function () {
if ($sidebar.is(":visible") === true) {
$sidebar.hide();