Browse Source

fix(element-nav): 动态添加元素渲染异常 (#2276)

pull/2284/head
morning-star 1 month ago committed by GitHub
parent
commit
a1491c1936
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 68
      src/modules/element.js

68
src/modules/element.js

@ -499,44 +499,44 @@ layui.define('jquery', function(exports){
var itemElem = othis.find('.'+NAV_ITEM); var itemElem = othis.find('.'+NAV_ITEM);
// hover 滑动效果 // hover 滑动效果
if (!othis.find('.'+NAV_BAR)[0]) { var hasBarElem = othis.find('.'+NAV_BAR)[0];
othis.append(bar); if (hasBarElem) hasBarElem.remove();
( othis.hasClass(NAV_TREE) othis.append(bar);
? itemElem.find('dd,>.'+ NAV_TITLE) ( othis.hasClass(NAV_TREE)
: itemElem ? itemElem.find('dd,>.'+ NAV_TITLE)
).on('mouseenter', function() { : itemElem
follow.call(this, bar, othis, index); ).off('mouseenter.lay_nav').on('mouseenter.lay_nav', function() {
}).on('mouseleave', function() { // 鼠标移出 follow.call(this, bar, othis, index);
// 是否为垂直导航 }).off('mouseleave.lay_nav').on('mouseleave.lay_nav', function() { // 鼠标移出
if (othis.hasClass(NAV_TREE)) { // 是否为垂直导航
if (othis.hasClass(NAV_TREE)) {
bar.css({
height: 0,
opacity: 0
});
} else {
// 隐藏子菜单
clearTimeout(timerMore[index]);
timerMore[index] = setTimeout(function(){
othis.find('.'+ NAV_CHILD).removeClass(SHOW);
othis.find('.'+ NAV_MORE).removeClass(NAV_MORE +'d');
}, 300);
}
});
// 鼠标离开当前菜单时
othis.off('mouseleave.lay_nav').on('mouseleave.lay_nav', function() {
clearTimeout(timer[index])
timeEnd[index] = setTimeout(function() {
if (!othis.hasClass(NAV_TREE)) {
bar.css({ bar.css({
height: 0, width: 0,
left: bar.position().left + bar.width() / 2,
opacity: 0 opacity: 0
}); });
} else {
// 隐藏子菜单
clearTimeout(timerMore[index]);
timerMore[index] = setTimeout(function(){
othis.find('.'+ NAV_CHILD).removeClass(SHOW);
othis.find('.'+ NAV_MORE).removeClass(NAV_MORE +'d');
}, 300);
} }
}); }, TIME);
});
// 鼠标离开当前菜单时
othis.on('mouseleave', function() {
clearTimeout(timer[index])
timeEnd[index] = setTimeout(function() {
if (!othis.hasClass(NAV_TREE)) {
bar.css({
width: 0,
left: bar.position().left + bar.width() / 2,
opacity: 0
});
}
}, TIME);
});
}
// 展开子菜单 // 展开子菜单
itemElem.find('a').each(function() { itemElem.find('a').each(function() {

Loading…
Cancel
Save