在使用malihu-custom-scrollbar-plugin-master的時候,發現初始化後的父標籤內部若是有原生滾動區域的時候會出現滾動失效問題;查詢接口發現以下問題:ide
$("#content-1").mCustomScrollbar({ autoHideScrollbar:true, theme:"rounded", mouseWheel:{ disableOver:["select","option","keygen","datalist","textarea", ".test_scroll"] // id和class無效 }, });
解決方案,拖拽對應的方法,使得id和class生效;spa
代碼以下:code
// TODO add by Guxignzhe _disableMousewheelByIdOrClass=function(el,target){ var id = target.id, classes = target.className, tags=el.data(pluginPfx).opt.mouseWheel.disableOver, focusTags=["select","textarea"]; if (id) { id = "#" + id; if ($.inArray(id,tags) > -1 && !($.inArray(id,focusTags) > -1 && !$(target).is(":focus"))) { return true; } } if (classes) { var classArr = $.trim(classes).split(/ +/g); for (var i in classArr) { classArr[i] = "." + classArr[i]; if ($.inArray(classArr[i],tags) > -1 && !($.inArray(classArr[i],focusTags) > -1 && !$(target).is(":focus"))) { return true; } } } },