Comparing version 3.1.11 to 3.1.12
@@ -137,3 +137,15 @@ var __values = this && this.__values || function (o) { | ||
} | ||
}; | ||
}; // 根据 event 计算激活键数量 | ||
function countKeyByEvent(event) { | ||
var countOfModifier = Object.keys(modifierKey).reduce(function (total, key) { | ||
if (modifierKey[key](event)) { | ||
return total + 1; | ||
} | ||
return total; | ||
}, 0); // 16 17 18 91 92 是修饰键的 keyCode,如果 keyCode 是修饰键,那么激活数量就是修饰键的数量,如果不是,那么就需要 +1 | ||
return [16, 17, 18, 91, 92].includes(event.keyCode) ? countOfModifier : countOfModifier + 1; | ||
} | ||
/** | ||
@@ -146,2 +158,3 @@ * 判断按键是否激活 | ||
function genFilterKey(event, keyFilter) { | ||
@@ -187,4 +200,11 @@ var e_1, _a; // 浏览器自动补全 input 的时候,会触发 keyDown、keyUp 事件,但此时 event.key 等为空 | ||
} | ||
/** | ||
* 需要判断触发的键位和监听的键位完全一致,判断方法就是触发的键位里有且等于监听的键位 | ||
* genLen === genArr.length 能判断出来触发的键位里有监听的键位 | ||
* countKeyByEvent(event) === genArr.length 判断出来触发的键位数量里有且等于监听的键位数量 | ||
* 主要用来防止按组合键其子集也会触发的情况,例如监听 ctrl+a 会触发监听 ctrl 和 a 两个键的事件。 | ||
*/ | ||
return genLen === genArr.length; | ||
return genLen === genArr.length && countKeyByEvent(event) === genArr.length; | ||
} | ||
@@ -191,0 +211,0 @@ /** |
@@ -152,3 +152,15 @@ "use strict"; | ||
} | ||
}; | ||
}; // 根据 event 计算激活键数量 | ||
function countKeyByEvent(event) { | ||
var countOfModifier = Object.keys(modifierKey).reduce(function (total, key) { | ||
if (modifierKey[key](event)) { | ||
return total + 1; | ||
} | ||
return total; | ||
}, 0); // 16 17 18 91 92 是修饰键的 keyCode,如果 keyCode 是修饰键,那么激活数量就是修饰键的数量,如果不是,那么就需要 +1 | ||
return [16, 17, 18, 91, 92].includes(event.keyCode) ? countOfModifier : countOfModifier + 1; | ||
} | ||
/** | ||
@@ -161,2 +173,3 @@ * 判断按键是否激活 | ||
function genFilterKey(event, keyFilter) { | ||
@@ -202,4 +215,11 @@ var e_1, _a; // 浏览器自动补全 input 的时候,会触发 keyDown、keyUp 事件,但此时 event.key 等为空 | ||
} | ||
/** | ||
* 需要判断触发的键位和监听的键位完全一致,判断方法就是触发的键位里有且等于监听的键位 | ||
* genLen === genArr.length 能判断出来触发的键位里有监听的键位 | ||
* countKeyByEvent(event) === genArr.length 判断出来触发的键位数量里有且等于监听的键位数量 | ||
* 主要用来防止按组合键其子集也会触发的情况,例如监听 ctrl+a 会触发监听 ctrl 和 a 两个键的事件。 | ||
*/ | ||
return genLen === genArr.length; | ||
return genLen === genArr.length && countKeyByEvent(event) === genArr.length; | ||
} | ||
@@ -206,0 +226,0 @@ /** |
{ | ||
"name": "ahooks", | ||
"version": "3.1.11", | ||
"version": "3.1.12", | ||
"description": "react hooks library", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"gitHead": "f18b1f38f6f2f4180a244354fb73a13494b1cf4b" | ||
"gitHead": "6d5bda4efbef756056511d23ddc2bcb0327344c3" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
634301
15738