MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / sidebarScrollFix

Function sidebarScrollFix

examples/js/sidebar.js:41–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40//侧边栏滚动支持
41function sidebarScrollFix() {
42 $('ul#sidebar-menu>li').hover(function (evt) {
43
44 if (!$('body').hasClass('sidebar-collapse')) {
45 return;
46 }
47
48 //调整一级菜单li下标题的布局位置至右侧
49 var $titleBar = $(this).children('a').children('.sidebar-title-bar');
50 $titleBar.css({
51 "top": ($(this).offset().top - $(window).scrollTop()) + "px",
52 //fix由于侧边栏滚动条宽度引起的减少的宽度
53 "width": "233px"
54 });
55
56 var visibleOffsetTop = $(this).offset().top - $(window).scrollTop();
57
58 //调整一级菜单li下子列表的布局位置至右侧
59 var offsetTop = visibleOffsetTop + $(this).height();
60 $(this).children('ul').css({
61 "top": offsetTop + "px"
62 });
63
64 //fix小尺寸屏幕下二级菜单高度高于窗口高度时显示不全的情况
65 var $activeList = $(this).children('ul');
66 var maxHeight = Math.abs($(window).height() - offsetTop);
67 $activeList.css({
68 "max-height": maxHeight
69 });
70 $activeList.addClass('scroll-list');
71 }, function (evt) {
72 if (!$('body').hasClass('sidebar-collapse')) {
73 return;
74 }
75 //滚动条
76 $(this).children('ul').removeClass('scroll-list');
77 //恢复原来的高度
78 $(this).children('ul').css({
79 "max-height": ''
80 });
81 });
82 $('.main-sidebar').on('scroll', function (evt) {
83 evt.stopPropagation();
84 });
85
86 $(window).on('resize', function () {
87 $('.sidebar-menu').css({
88 "height": "100%"
89 })
90 })
91}
92
93//创建菜单项
94function createSideBarMenuItem(id, config, containAll) {

Callers 2

editor.jsFile · 0.85
initPageFunction · 0.85

Calls 4

childrenMethod · 0.80
offsetMethod · 0.80
$Function · 0.50
onMethod · 0.45

Tested by

no test coverage detected