nhanh-pure-function 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/User.js +13 -12
- package/package.json +1 -1
package/lib/User.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { _IsObject, _NotNull } from "./Utility";
|
|
1
|
+
import { _IsObject, _NotNull, _Debounce } from "./Utility";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 滚动触底事件
|
|
5
5
|
* @param {触底事件} callback
|
|
6
6
|
*/
|
|
7
7
|
export function _ScrollBottomListener(callback) {
|
|
8
|
+
const debouncedCallback = _Debounce(callback, 100);
|
|
9
|
+
let lastScrollTop = 0;
|
|
8
10
|
return function (payload) {
|
|
9
11
|
const target = payload.target;
|
|
10
12
|
const { scrollTop, scrollHeight, clientHeight } = target;
|
|
13
|
+
/** 向上滚动? */
|
|
14
|
+
const isUp = lastScrollTop > scrollTop;
|
|
15
|
+
lastScrollTop = scrollTop;
|
|
16
|
+
if (isUp) return;
|
|
11
17
|
const bottom = scrollHeight - scrollTop - clientHeight;
|
|
12
|
-
if (bottom <= 1)
|
|
13
|
-
callback();
|
|
14
|
-
}
|
|
18
|
+
if (bottom <= 1) debouncedCallback();
|
|
15
19
|
};
|
|
16
20
|
}
|
|
17
21
|
|
|
@@ -390,19 +394,16 @@ export class _LoadingController {
|
|
|
390
394
|
* @param options.uiLibrary 项目使用的 ui库 , 用于排除 ui库 创建的元素 , 避免点击 ui库 创建的元素时意外的执行 callback
|
|
391
395
|
* @param options.isClickAllowed 是否允许该点击 ( 如果不确定可以返回 undefined )
|
|
392
396
|
*/
|
|
393
|
-
export function _CloseOnOutsideClick(
|
|
394
|
-
querySelector,
|
|
395
|
-
callback,
|
|
396
|
-
options = {
|
|
397
|
-
uiLibrary: ["naiveUI", "ElementPlus", "Element"],
|
|
398
|
-
}
|
|
399
|
-
) {
|
|
397
|
+
export function _CloseOnOutsideClick(querySelector, callback, options) {
|
|
400
398
|
function end() {
|
|
401
399
|
callback();
|
|
402
400
|
document.removeEventListener("mousedown", mousedown);
|
|
403
401
|
}
|
|
404
402
|
function mousedown(event) {
|
|
405
|
-
const {
|
|
403
|
+
const {
|
|
404
|
+
isClickAllowed,
|
|
405
|
+
uiLibrary = ["naiveUI", "ElementPlus", "Element"],
|
|
406
|
+
} = options || {};
|
|
406
407
|
|
|
407
408
|
if (isClickAllowed) {
|
|
408
409
|
const bool = isClickAllowed(event);
|