小改动;
parent
68088578de
commit
044c830894
|
|
@ -60,8 +60,13 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
superWidth = parseInt(superEle.width()) - 40 * 3,//可显示的宽度
|
superWidth = parseInt(superEle.width()) - 40 * 3,//可显示的宽度
|
||||||
subWidth = ele.outerWidth(),//当前元素宽度
|
subWidth = ele.outerWidth(),//当前元素宽度
|
||||||
elePrevAll = ele.prevAll(),//左边的所有同级元素
|
elePrevAll = ele.prevAll(),//左边的所有同级元素
|
||||||
leftWidth = 0;//左边距离
|
leftWidth = 0,//左边距离
|
||||||
|
postLeft = Math.abs(contEle.position().left);//当前移动的位置
|
||||||
|
var maxMoveWidth = contWidth - superWidth;//最大可移动的宽度
|
||||||
|
|
||||||
|
/*console.log("maxMoveWidth:" + maxMoveWidth);
|
||||||
|
console.log("superWidth:" + superWidth);
|
||||||
|
console.log("contWidth:" + contWidth);*/
|
||||||
for (let i = 0; i < elePrevAll.length; i++) {
|
for (let i = 0; i < elePrevAll.length; i++) {
|
||||||
leftWidth += $(elePrevAll[i]).outerWidth() * 1;
|
leftWidth += $(elePrevAll[i]).outerWidth() * 1;
|
||||||
}
|
}
|
||||||
|
|
@ -69,24 +74,29 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
/**
|
/**
|
||||||
* 移动tab栏的位置
|
* 移动tab栏的位置
|
||||||
*/
|
*/
|
||||||
if (leftWidth + subWidth > superWidth) {
|
var showPost = leftWidth - postLeft;//当前点击的元素位置(显示区域的位置)
|
||||||
var moveWidth = leftWidth - subWidth;
|
var halfPlace = parseInt(superWidth / 2);//可显示的宽度的一半
|
||||||
if (moveWidth > contWidth - superWidth) {
|
|
||||||
contEle.animate({
|
if (halfPlace < showPost) {//从右往左移动
|
||||||
left: -(contWidth - superWidth)
|
var tempMove = leftWidth - subWidth;//预留一部分距离
|
||||||
}, 50);
|
if(tempMove > maxMoveWidth){//当前移动的距离超过最大可移动的宽度
|
||||||
} else {
|
tempMove = maxMoveWidth;
|
||||||
contEle.animate({
|
|
||||||
left: -moveWidth
|
|
||||||
}, 50);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
contEle.animate({
|
contEle.animate({
|
||||||
left: -leftWidth
|
left: -tempMove
|
||||||
|
}, 50);
|
||||||
|
}else{//从左往右移动
|
||||||
|
console.log("从左往右移动");
|
||||||
|
var tempMove = leftWidth - halfPlace;//预留一部分距离
|
||||||
|
if(tempMove < 0){
|
||||||
|
tempMove = 0;
|
||||||
|
}
|
||||||
|
contEle.animate({
|
||||||
|
left: -tempMove
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 左侧菜单的样式和多级菜单的展开
|
* 左侧菜单的样式和多级菜单的展开
|
||||||
*/
|
*/
|
||||||
|
|
@ -223,13 +233,13 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
if (data.children != undefined && data.children.length > 0) {
|
if (data.children != undefined && data.children.length > 0) {
|
||||||
temp += '<a>';
|
temp += '<a>';
|
||||||
if (data.icon != undefined && data.icon != '') {
|
if (data.icon != undefined && data.icon != '') {
|
||||||
if(!data.fontFamily || data.fontFamily.indexOf("layui-icon") >= 0){
|
if (!data.fontFamily || data.fontFamily.indexOf("layui-icon") >= 0) {
|
||||||
if (data.icon.indexOf("&#") >= 0) {
|
if (data.icon.indexOf("&#") >= 0) {
|
||||||
temp += ('<i class="layui-icon">{0}</i>').format(data.icon);
|
temp += ('<i class="layui-icon">{0}</i>').format(data.icon);
|
||||||
}else{
|
} else {
|
||||||
temp += ('<i class="layui-icon {0}"></i>').format(data.icon);
|
temp += ('<i class="layui-icon {0}"></i>').format(data.icon);
|
||||||
}
|
}
|
||||||
}else if (data.fontFamily) {
|
} else if (data.fontFamily) {
|
||||||
if (data.icon.indexOf("&#") >= 0) {
|
if (data.icon.indexOf("&#") >= 0) {
|
||||||
temp += ('<i class="{0}">{1}</i>').format(data.fontFamily, data.icon);
|
temp += ('<i class="{0}">{1}</i>').format(data.fontFamily, data.icon);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -256,13 +266,13 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
temp += ('<a lay-id="{0}" data-url="{1}" is-close="{2}">').format(tabID, data.href, isClose);
|
temp += ('<a lay-id="{0}" data-url="{1}" is-close="{2}">').format(tabID, data.href, isClose);
|
||||||
}
|
}
|
||||||
if (data.icon != undefined && data.icon != '') {
|
if (data.icon != undefined && data.icon != '') {
|
||||||
if(!data.fontFamily || data.fontFamily.indexOf("layui-icon") >= 0){
|
if (!data.fontFamily || data.fontFamily.indexOf("layui-icon") >= 0) {
|
||||||
if (data.icon.indexOf("&#") >= 0) {
|
if (data.icon.indexOf("&#") >= 0) {
|
||||||
temp += ('<i class="layui-icon">{0}</i>').format(data.icon);
|
temp += ('<i class="layui-icon">{0}</i>').format(data.icon);
|
||||||
}else{
|
} else {
|
||||||
temp += ('<i class="layui-icon {0}"></i>').format(data.icon);
|
temp += ('<i class="layui-icon {0}"></i>').format(data.icon);
|
||||||
}
|
}
|
||||||
}else if (data.fontFamily) {
|
} else if (data.fontFamily) {
|
||||||
if (data.icon.indexOf("&#") >= 0) {
|
if (data.icon.indexOf("&#") >= 0) {
|
||||||
temp += ('<i class="{0}">{1}</i>').format(data.fontFamily, data.icon);
|
temp += ('<i class="{0}">{1}</i>').format(data.fontFamily, data.icon);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -400,6 +410,7 @@ layui.define(["element", "jquery"], function (exports) {
|
||||||
tips: [1, '#000'],
|
tips: [1, '#000'],
|
||||||
time: 2000
|
time: 2000
|
||||||
});
|
});
|
||||||
|
moveLeft = -moveWidth;
|
||||||
}
|
}
|
||||||
if (superWidth + Math.abs(moveLeft) >= contWidth) {
|
if (superWidth + Math.abs(moveLeft) >= contWidth) {
|
||||||
moveLeft = -moveWidth;
|
moveLeft = -moveWidth;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue