diff --git a/component/pear/module/menu.js b/component/pear/module/menu.js
index 33cde7f4a024eb328d44ee98c8a633b33b786b27..85cceba6580f412943fdf9d2d25e68bbacf807ab 100644
--- a/component/pear/module/menu.js
+++ b/component/pear/module/menu.js
@@ -57,31 +57,6 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
// 处理高度
$("#" + opt.elem).height(option.height)
- setTimeout(function () {
- $("#" + opt.control + " .control").on("mousewheel DOMMouseScroll", function (event) {
-
- var delta = (event.originalEvent.wheelDelta && (event.originalEvent.wheelDelta > 0 ? 1 : -1)) || // chrome & ie
- (event.originalEvent.detail && (event.originalEvent.detail > 0 ? -1 : 1)); // firefox
-
- if (delta > 0) {
- for (var num = 1; num < 20; num++) {
- setTimeout(function () {
- if ($("#" + opt.control + " .control ul").css('left').replace("px", "") < 0) {
- $("#" + opt.control + " .control ul").css("left", "+=2px");
- }
- }, 10)
- }
- } else if (delta < 0) {
- if (((Number)($("#" + opt.control + " .control ul").css("left").replace("px", "")) + ($("#" + opt.control + " .control ul").width() - $("#" + opt.control + " .control").width())) > 0) {
- for (var num = 1; num < 20; num++) {
- setTimeout(function () {
- $("#" + opt.control + " .control ul").css("left", "-=2px");
- }, 10)
- }
- }
- }
- });
- }, 1000)
return new pearMenu(option);
}
@@ -322,7 +297,8 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
}
function createMenuAndControl(option) {
- var control = '
';
+ var control = '';
+ control+= '
';
var controlPe = '';
// 声 明 头 部
var menu = ''
@@ -551,10 +527,57 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
rationalizeWidth = $headerControl.parent().innerWidth() - $headerControl.position().left;
}
- if (option.controlWidth && rationalizeWidth >= option.controlWidth) {
- rationalizeWidth = option.controlWidth;
- }
- $("#" + option.control + " .control").css({ "width": rationalizeWidth, "transition": "width .15s" });
+ $("#" + option.control + " .control").css({"width": rationalizeWidth});
+
+ var navobj = $("#" + option.control+' ul.pear-nav-control.pc');
+ var dropdown = $(".tabdrop", navobj);
+
+ var collection = 0;
+ var maxwidth = rationalizeWidth - 60;
+
+ var liwidth = 0;
+ //检查超过一行的标签页
+ $('.tabdrop').find('dd').each(function(){
+ var newLI = $('
').html($(this).html());
+ newLI.addClass('layui-nav-item');
+ newLI.attr('pear-href', $(this).attr('pear-href'));
+ newLI.attr('pear-title', $(this).attr('pear-title'));
+ newLI.attr('pear-id', $(this).attr('pear-id'));
+ navobj.append(newLI);
+ $(this).remove();
+
+ })
+ var litabs = navobj.find('>li').not('.tabdrop');
+
+ var totalwidth = 0;
+ litabs.each(function () {
+ totalwidth += $(this).outerWidth(true);
+ });
+
+ if (rationalizeWidth < totalwidth) {
+ litabs.each(function () {
+ liwidth += $(this).outerWidth(true);
+ if (liwidth > maxwidth) {
+ var newDD = $('').html($(this).html());
+ newDD.attr('pear-href', $(this).attr('pear-href'));
+ newDD.attr('pear-title', $(this).attr('pear-title'));
+ newDD.attr('pear-id', $(this).attr('pear-id'));
+ dropdown.find('dl').append(newDD);
+ collection++;
+ $(this).remove();
+ }
+ });
+ if (collection > 0) {
+ dropdown.removeClass('layui-hide');
+ if (dropdown.find('.active').length === 1) {
+ dropdown.addClass('active');
+ } else {
+ dropdown.removeClass('active');
+ }
+ }
+ }else {
+ dropdown.addClass('layui-hide');
+ }
}
function rationalizeHeaderControlWidthAuto(option){