Skip to content

Commit 323047e

Browse files
committed
[fix] 修复示例editor页面,左侧菜单折叠状态下:
1)左侧二级菜单显示不完整的问题; 2)在菜单栏上,滚动鼠标,菜单图标会滚出范围消失的问题; review by luox
1 parent 9fa64f5 commit 323047e

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

examples/js/sidebar.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,7 @@ function sidebarScrollFix() {
2727
"width": "233px"
2828
});
2929

30-
//如果底部空间不够,动态增加侧边栏高度
3130
var visibleOffsetTop = $(this).offset().top - $(window).scrollTop();
32-
var offsetBottom = $('.sidebar-menu').height() - visibleOffsetTop;
33-
var requireVisibleHeight = $(this).height() + $(this).children('ul').height();
34-
if (offsetBottom <= requireVisibleHeight) {
35-
$('.sidebar-menu').css({
36-
"height": (requireVisibleHeight + $(window).height()) + "px"
37-
})
38-
}
3931

4032
//调整一级菜单li下子列表的布局位置至右侧
4133
var offsetTop = visibleOffsetTop + $(this).height();
@@ -45,16 +37,11 @@ function sidebarScrollFix() {
4537

4638
//fix小尺寸屏幕下二级菜单高度高于窗口高度时显示不全的情况
4739
var $activeList = $(this).children('ul');
48-
var activeListOffsetBottom = Math.abs($(window).height() - visibleOffsetTop - $(this).height());
49-
var requireActiveListHeight = $activeList.height();
50-
if (activeListOffsetBottom < requireActiveListHeight) {
51-
$activeList.css({
52-
"height": requireActiveListHeight
53-
});
54-
//滚动条样式
55-
$activeList.addClass('scroll-list');
56-
}
57-
40+
var maxHeight = Math.abs($(window).height() - offsetTop);
41+
$activeList.css({
42+
"max-height": maxHeight
43+
});
44+
$activeList.addClass('scroll-list');
5845
}, function (evt) {
5946
if (!$('body').hasClass('sidebar-collapse')) {
6047
return;
@@ -63,7 +50,7 @@ function sidebarScrollFix() {
6350
$(this).children('ul').removeClass('scroll-list');
6451
//恢复原来的高度
6552
$(this).children('ul').css({
66-
"height": "auto"
53+
"max-height": ''
6754
});
6855
});
6956
$('.main-sidebar').on('scroll', function (evt) {

0 commit comments

Comments
 (0)