Comparing version 1.0.1 to 1.0.2
@@ -215,3 +215,3 @@ import $ from 'mdui.jq/es/$'; | ||
if (tab.id === index) { | ||
this.activeIndex === i; | ||
this.activeIndex = i; | ||
return false; | ||
@@ -218,0 +218,0 @@ } |
{ | ||
"name": "mdui", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "a CSS Framework based on material design", | ||
@@ -16,3 +16,6 @@ "main": "dist/js/mdui.js", | ||
"css": "npm run stylelint && gulp", | ||
"build": "npm run js && npm run css" | ||
"build": "npm run js && npm run css", | ||
"_postinstall": "husky install", | ||
"prepublishOnly": "pinst --disable", | ||
"postpublish": "pinst --enable" | ||
}, | ||
@@ -27,7 +30,2 @@ "files": [ | ||
], | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run build" | ||
} | ||
}, | ||
"repository": { | ||
@@ -60,11 +58,11 @@ "type": "git", | ||
"@rollup/plugin-buble": "^0.21.3", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@rollup/plugin-typescript": "^6.1.0", | ||
"@typescript-eslint/eslint-plugin": "^4.6.0", | ||
"@typescript-eslint/parser": "^4.6.0", | ||
"autoprefixer": "^10.0.1", | ||
"eslint": "^7.12.1", | ||
"eslint-config-prettier": "^6.15.0", | ||
"@rollup/plugin-node-resolve": "^11.2.0", | ||
"@rollup/plugin-typescript": "^8.2.0", | ||
"@typescript-eslint/eslint-plugin": "^4.15.1", | ||
"@typescript-eslint/parser": "^4.15.1", | ||
"autoprefixer": "^10.2.4", | ||
"eslint": "^7.20.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"gulp": "^4.0.2", | ||
@@ -76,15 +74,16 @@ "gulp-autoprefixer": "^7.0.1", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-sourcemaps": "^2.6.5", | ||
"husky": "^4.3.0", | ||
"postcss": "^8.1.4", | ||
"prettier": "^2.1.2", | ||
"rollup": "^2.32.1", | ||
"gulp-sourcemaps": "^3.0.0", | ||
"husky": "^5.0.9", | ||
"pinst": "^2.1.4", | ||
"postcss": "^8.2.6", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.39.0", | ||
"rollup-plugin-polyfill": "^3.0.0", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"stylelint": "^13.7.2", | ||
"stylelint": "^13.10.0", | ||
"stylelint-config-prettier": "^8.0.2", | ||
"stylelint-config-rational-order": "^0.1.2", | ||
"stylelint-config-standard": "^20.0.0", | ||
"tslib": "^2.0.3", | ||
"typescript": "^4.0.5" | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.1.5" | ||
}, | ||
@@ -91,0 +90,0 @@ "engines": { |
@@ -562,85 +562,87 @@ import $ from 'mdui.jq/es/$'; | ||
this.$element.on('mouseover mouseout', '.mdui-menu-item', function ( | ||
event, | ||
) { | ||
const $item = $(this as HTMLElement); | ||
const eventType = event.type; | ||
const $relatedTarget = $( | ||
(event as MouseEvent).relatedTarget as HTMLElement, | ||
); | ||
this.$element.on( | ||
'mouseover mouseout', | ||
'.mdui-menu-item', | ||
function (event) { | ||
const $item = $(this as HTMLElement); | ||
const eventType = event.type; | ||
const $relatedTarget = $( | ||
(event as MouseEvent).relatedTarget as HTMLElement, | ||
); | ||
// 禁用状态的菜单不操作 | ||
if ($item.attr('disabled') !== undefined) { | ||
return; | ||
} | ||
// 用 mouseover 模拟 mouseenter | ||
if (eventType === 'mouseover') { | ||
if ( | ||
!$item.is($relatedTarget) && | ||
contains($item[0], $relatedTarget[0]) | ||
) { | ||
// 禁用状态的菜单不操作 | ||
if ($item.attr('disabled') !== undefined) { | ||
return; | ||
} | ||
} | ||
// 用 mouseout 模拟 mouseleave | ||
else if (eventType === 'mouseout') { | ||
if ( | ||
$item.is($relatedTarget) || | ||
contains($item[0], $relatedTarget[0]) | ||
) { | ||
return; | ||
// 用 mouseover 模拟 mouseenter | ||
if (eventType === 'mouseover') { | ||
if ( | ||
!$item.is($relatedTarget) && | ||
contains($item[0], $relatedTarget[0]) | ||
) { | ||
return; | ||
} | ||
} | ||
} | ||
// 当前菜单项下的子菜单,未必存在 | ||
const $submenu = $item.children('.mdui-menu'); | ||
// 鼠标移入菜单项时,显示菜单项下的子菜单 | ||
if (eventType === 'mouseover') { | ||
if ($submenu.length) { | ||
// 当前子菜单准备打开时,如果当前子菜单正准备着关闭,不用再关闭了 | ||
const tmpClose = $submenu.data('timeoutClose.mdui.menu'); | ||
if (tmpClose) { | ||
clearTimeout(tmpClose); | ||
} | ||
// 如果当前子菜单已经打开,不操作 | ||
if ($submenu.hasClass('mdui-menu-open')) { | ||
// 用 mouseout 模拟 mouseleave | ||
else if (eventType === 'mouseout') { | ||
if ( | ||
$item.is($relatedTarget) || | ||
contains($item[0], $relatedTarget[0]) | ||
) { | ||
return; | ||
} | ||
} | ||
// 当前子菜单准备打开时,其他准备打开的子菜单不用再打开了 | ||
clearTimeout(timeoutOpen); | ||
// 当前菜单项下的子菜单,未必存在 | ||
const $submenu = $item.children('.mdui-menu'); | ||
// 准备打开当前子菜单 | ||
timeout = timeoutOpen = setTimeout( | ||
() => that.openSubMenu($submenu), | ||
that.options.subMenuDelay, | ||
); | ||
// 鼠标移入菜单项时,显示菜单项下的子菜单 | ||
if (eventType === 'mouseover') { | ||
if ($submenu.length) { | ||
// 当前子菜单准备打开时,如果当前子菜单正准备着关闭,不用再关闭了 | ||
const tmpClose = $submenu.data('timeoutClose.mdui.menu'); | ||
if (tmpClose) { | ||
clearTimeout(tmpClose); | ||
} | ||
$submenu.data('timeoutOpen.mdui.menu', timeout); | ||
} | ||
} | ||
// 如果当前子菜单已经打开,不操作 | ||
if ($submenu.hasClass('mdui-menu-open')) { | ||
return; | ||
} | ||
// 鼠标移出菜单项时,关闭菜单项下的子菜单 | ||
else if (eventType === 'mouseout') { | ||
if ($submenu.length) { | ||
// 鼠标移出菜单项时,如果当前菜单项下的子菜单正准备打开,不用再打开了 | ||
const tmpOpen = $submenu.data('timeoutOpen.mdui.menu'); | ||
if (tmpOpen) { | ||
clearTimeout(tmpOpen); | ||
// 当前子菜单准备打开时,其他准备打开的子菜单不用再打开了 | ||
clearTimeout(timeoutOpen); | ||
// 准备打开当前子菜单 | ||
timeout = timeoutOpen = setTimeout( | ||
() => that.openSubMenu($submenu), | ||
that.options.subMenuDelay, | ||
); | ||
$submenu.data('timeoutOpen.mdui.menu', timeout); | ||
} | ||
} | ||
// 准备关闭当前子菜单 | ||
timeout = setTimeout( | ||
() => that.closeSubMenu($submenu), | ||
that.options.subMenuDelay, | ||
); | ||
// 鼠标移出菜单项时,关闭菜单项下的子菜单 | ||
else if (eventType === 'mouseout') { | ||
if ($submenu.length) { | ||
// 鼠标移出菜单项时,如果当前菜单项下的子菜单正准备打开,不用再打开了 | ||
const tmpOpen = $submenu.data('timeoutOpen.mdui.menu'); | ||
if (tmpOpen) { | ||
clearTimeout(tmpOpen); | ||
} | ||
$submenu.data('timeoutClose.mdui.menu', timeout); | ||
// 准备关闭当前子菜单 | ||
timeout = setTimeout( | ||
() => that.closeSubMenu($submenu), | ||
that.options.subMenuDelay, | ||
); | ||
$submenu.data('timeoutClose.mdui.menu', timeout); | ||
} | ||
} | ||
} | ||
}); | ||
}, | ||
); | ||
} | ||
@@ -647,0 +649,0 @@ } |
@@ -313,3 +313,3 @@ import $ from 'mdui.jq/es/$'; | ||
if (tab.id === index) { | ||
this.activeIndex === i; | ||
this.activeIndex = i; | ||
return false; | ||
@@ -316,0 +316,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
39708
8486713
30
330