@bifrostui/utils 1.1.11-beta.0 → 1.1.11-beta.4
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/README.md +3 -0
- package/dist/debounce.js +4 -4
- package/dist/domTarget.js +0 -2
- package/dist/getBoundingClientRect/index.js +0 -2
- package/dist/getBoundingClientRect/index.miniapp.js +0 -2
- package/dist/hex2rgba.js +1 -3
- package/dist/hooks/index.js +0 -2
- package/dist/hooks/useDidMountEffect.js +5 -5
- package/dist/hooks/useDomCss/index.js +0 -2
- package/dist/hooks/useDomCss/index.miniapp.js +0 -2
- package/dist/hooks/useDomReady/index.js +0 -2
- package/dist/hooks/useDomReady/index.miniapp.js +0 -2
- package/dist/hooks/useEventCallback.js +0 -2
- package/dist/hooks/useForkRef.js +0 -2
- package/dist/hooks/useMemoizedFn.js +0 -2
- package/dist/hooks/useSize.js +0 -2
- package/dist/hooks/useTouch.js +4 -5
- package/dist/hooks/useTouchEmulator.js +3 -5
- package/dist/hooks/useValue.js +0 -2
- package/dist/index.js +0 -2
- package/dist/isDev.js +1 -3
- package/dist/isMini.js +4 -6
- package/dist/isType.js +1 -3
- package/dist/setRef.js +0 -2
- package/dist/throttle.js +2 -3
- package/dist/toArray.js +0 -2
- package/dist/touchBlocker.js +6 -5
- package/dist/transitions.js +29 -19
- package/es/debounce.js +12 -11
- package/es/domTarget.js +8 -5
- package/es/getBoundingClientRect/index.js +5 -2
- package/es/getBoundingClientRect/index.miniapp.js +9 -14
- package/es/hex2rgba.js +12 -19
- package/es/hooks/index.js +11 -1
- package/es/hooks/useDidMountEffect.js +12 -9
- package/es/hooks/useDomCss/index.js +11 -8
- package/es/hooks/useDomCss/index.miniapp.js +12 -9
- package/es/hooks/useDomReady/index.js +7 -4
- package/es/hooks/useDomReady/index.miniapp.js +8 -5
- package/es/hooks/useEventCallback.js +9 -16
- package/es/hooks/useForkRef.js +10 -18
- package/es/hooks/useMemoizedFn.js +13 -14
- package/es/hooks/useSize.js +10 -19
- package/es/hooks/useTouch.js +47 -47
- package/es/hooks/useTouchEmulator.js +34 -90
- package/es/hooks/useValue.js +24 -32
- package/es/index.js +54 -12
- package/es/isDev.js +5 -2
- package/es/isMini.js +11 -6
- package/es/isType.js +6 -4
- package/es/setRef.js +6 -3
- package/es/throttle.js +16 -34
- package/es/toArray.js +10 -8
- package/es/touchBlocker.js +59 -62
- package/es/transitions.js +57 -45
- package/package.json +13 -7
- package/src/index.ts +27 -0
package/README.md
CHANGED
package/dist/debounce.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/debounce.ts
|
20
18
|
var debounce_exports = {};
|
21
19
|
__export(debounce_exports, {
|
22
20
|
default: () => debounce
|
@@ -25,11 +23,13 @@ module.exports = __toCommonJS(debounce_exports);
|
|
25
23
|
function debounce(func, wait, immediate) {
|
26
24
|
let timeout;
|
27
25
|
return function(...args) {
|
28
|
-
if (immediate && !timeout)
|
26
|
+
if (immediate && !timeout)
|
27
|
+
func.apply(this, args);
|
29
28
|
clearTimeout(timeout);
|
30
29
|
timeout = setTimeout(() => {
|
31
30
|
timeout = null;
|
32
|
-
if (!immediate)
|
31
|
+
if (!immediate)
|
32
|
+
func.apply(this, args);
|
33
33
|
}, wait);
|
34
34
|
};
|
35
35
|
}
|
package/dist/domTarget.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/domTarget.ts
|
20
18
|
var domTarget_exports = {};
|
21
19
|
__export(domTarget_exports, {
|
22
20
|
getTargetElement: () => getTargetElement
|
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/getBoundingClientRect/index.ts
|
20
18
|
var getBoundingClientRect_exports = {};
|
21
19
|
__export(getBoundingClientRect_exports, {
|
22
20
|
default: () => getBoundingClientRect
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/getBoundingClientRect/index.miniapp.ts
|
30
28
|
var index_miniapp_exports = {};
|
31
29
|
__export(index_miniapp_exports, {
|
32
30
|
default: () => getBoundingClientRect
|
package/dist/hex2rgba.js
CHANGED
@@ -15,14 +15,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/hex2rgba.ts
|
20
18
|
var hex2rgba_exports = {};
|
21
19
|
__export(hex2rgba_exports, {
|
22
20
|
default: () => hex2rgba_default
|
23
21
|
});
|
24
22
|
module.exports = __toCommonJS(hex2rgba_exports);
|
25
|
-
|
23
|
+
const convertHexToRGBA = (hexCode, opacity = 1) => {
|
26
24
|
let hex = hexCode.replace("#", "");
|
27
25
|
if (hex.length === 3) {
|
28
26
|
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
|
package/dist/hooks/index.js
CHANGED
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/index.ts
|
30
28
|
var hooks_exports = {};
|
31
29
|
__export(hooks_exports, {
|
32
30
|
useDidMountEffect: () => import_useDidMountEffect.default,
|
@@ -15,19 +15,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/hooks/useDidMountEffect.ts
|
20
18
|
var useDidMountEffect_exports = {};
|
21
19
|
__export(useDidMountEffect_exports, {
|
22
20
|
default: () => useDidMountEffect_default
|
23
21
|
});
|
24
22
|
module.exports = __toCommonJS(useDidMountEffect_exports);
|
25
23
|
var import_react = require("react");
|
26
|
-
|
24
|
+
const useDidMountEffect = (func, deps) => {
|
27
25
|
const didMount = (0, import_react.useRef)(false);
|
28
26
|
(0, import_react.useEffect)(() => {
|
29
|
-
if (didMount.current)
|
30
|
-
|
27
|
+
if (didMount.current)
|
28
|
+
func();
|
29
|
+
else
|
30
|
+
didMount.current = true;
|
31
31
|
}, deps);
|
32
32
|
};
|
33
33
|
var useDidMountEffect_default = useDidMountEffect;
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useDomCss/index.ts
|
30
28
|
var useDomCss_exports = {};
|
31
29
|
__export(useDomCss_exports, {
|
32
30
|
default: () => useDomCss_default
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useDomCss/index.miniapp.ts
|
30
28
|
var index_miniapp_exports = {};
|
31
29
|
__export(index_miniapp_exports, {
|
32
30
|
default: () => index_miniapp_default
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useDomReady/index.ts
|
30
28
|
var useDomReady_exports = {};
|
31
29
|
__export(useDomReady_exports, {
|
32
30
|
default: () => useDomReady_default
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useDomReady/index.miniapp.ts
|
30
28
|
var index_miniapp_exports = {};
|
31
29
|
__export(index_miniapp_exports, {
|
32
30
|
default: () => index_miniapp_default
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useEventCallback.ts
|
30
28
|
var useEventCallback_exports = {};
|
31
29
|
__export(useEventCallback_exports, {
|
32
30
|
default: () => useEventCallback
|
package/dist/hooks/useForkRef.js
CHANGED
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useForkRef.ts
|
30
28
|
var useForkRef_exports = {};
|
31
29
|
__export(useForkRef_exports, {
|
32
30
|
default: () => useForkRef
|
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useMemoizedFn.ts
|
30
28
|
var useMemoizedFn_exports = {};
|
31
29
|
__export(useMemoizedFn_exports, {
|
32
30
|
default: () => useMemoizedFn
|
package/dist/hooks/useSize.js
CHANGED
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/hooks/useSize.ts
|
30
28
|
var useSize_exports = {};
|
31
29
|
__export(useSize_exports, {
|
32
30
|
default: () => useSize_default
|
package/dist/hooks/useTouch.js
CHANGED
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __pow = Math.pow;
|
5
6
|
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -15,15 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
16
|
return to;
|
16
17
|
};
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/hooks/useTouch.ts
|
20
19
|
var useTouch_exports = {};
|
21
20
|
__export(useTouch_exports, {
|
22
21
|
default: () => useTouch_default
|
23
22
|
});
|
24
23
|
module.exports = __toCommonJS(useTouch_exports);
|
25
24
|
var import_react = require("react");
|
26
|
-
|
25
|
+
const MIN_DISTANCE = 10;
|
27
26
|
function getDirection(x, y) {
|
28
27
|
if (x > y && x > MIN_DISTANCE) {
|
29
28
|
return "horizontal";
|
@@ -33,7 +32,7 @@ function getDirection(x, y) {
|
|
33
32
|
}
|
34
33
|
return "";
|
35
34
|
}
|
36
|
-
|
35
|
+
const useTouch = () => {
|
37
36
|
const startX = (0, import_react.useRef)(0);
|
38
37
|
const startY = (0, import_react.useRef)(0);
|
39
38
|
const deltaX = (0, import_react.useRef)(0);
|
@@ -76,7 +75,7 @@ var useTouch = () => {
|
|
76
75
|
};
|
77
76
|
const end = () => {
|
78
77
|
last.current = true;
|
79
|
-
velocity.current = Math.sqrt(deltaX.current
|
78
|
+
velocity.current = Math.sqrt(__pow(deltaX.current, 2) + __pow(deltaY.current, 2)) / (Date.now() - touchTime.current);
|
80
79
|
};
|
81
80
|
return {
|
82
81
|
end,
|
@@ -15,16 +15,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/hooks/useTouchEmulator.ts
|
20
18
|
var useTouchEmulator_exports = {};
|
21
19
|
__export(useTouchEmulator_exports, {
|
22
20
|
default: () => useTouchEmulator
|
23
21
|
});
|
24
22
|
module.exports = __toCommonJS(useTouchEmulator_exports);
|
25
23
|
var import_react = require("react");
|
26
|
-
|
27
|
-
|
24
|
+
let eventTarget;
|
25
|
+
const Touch = function Touch2(target, identifier, pos, deltaX, deltaY) {
|
28
26
|
deltaX = deltaX || 0;
|
29
27
|
deltaY = deltaY || 0;
|
30
28
|
this.identifier = identifier;
|
@@ -46,7 +44,7 @@ function TouchList() {
|
|
46
44
|
};
|
47
45
|
return touchList;
|
48
46
|
}
|
49
|
-
|
47
|
+
let initiated = false;
|
50
48
|
function onMouse(touchType) {
|
51
49
|
return function(ev) {
|
52
50
|
if (ev.type === "mousedown") {
|
package/dist/hooks/useValue.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/hooks/useValue.ts
|
20
18
|
var useValue_exports = {};
|
21
19
|
__export(useValue_exports, {
|
22
20
|
default: () => useValue
|
package/dist/index.js
CHANGED
@@ -26,8 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
26
26
|
mod
|
27
27
|
));
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/index.ts
|
31
29
|
var src_exports = {};
|
32
30
|
__export(src_exports, {
|
33
31
|
blockTouch: () => import_touchBlocker.default,
|
package/dist/isDev.js
CHANGED
@@ -15,12 +15,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/isDev.ts
|
20
18
|
var isDev_exports = {};
|
21
19
|
__export(isDev_exports, {
|
22
20
|
default: () => isDev_default
|
23
21
|
});
|
24
22
|
module.exports = __toCommonJS(isDev_exports);
|
25
|
-
|
23
|
+
const isDev = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
26
24
|
var isDev_default = isDev;
|
package/dist/isMini.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/isMini.ts
|
20
18
|
var isMini_exports = {};
|
21
19
|
__export(isMini_exports, {
|
22
20
|
isAlipay: () => isAlipay,
|
@@ -25,10 +23,10 @@ __export(isMini_exports, {
|
|
25
23
|
isWeapp: () => isWeapp
|
26
24
|
});
|
27
25
|
module.exports = __toCommonJS(isMini_exports);
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
const isMini = typeof process.env.TARO_ENV === "string";
|
27
|
+
const isWeapp = process.env.TARO_ENV === "weapp";
|
28
|
+
const isAlipay = process.env.TARO_ENV === "alipay";
|
29
|
+
const isMiniapp = () => {
|
32
30
|
return isMini;
|
33
31
|
};
|
34
32
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/isType.js
CHANGED
@@ -15,14 +15,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/isType.ts
|
20
18
|
var isType_exports = {};
|
21
19
|
__export(isType_exports, {
|
22
20
|
isFunction: () => isFunction
|
23
21
|
});
|
24
22
|
module.exports = __toCommonJS(isType_exports);
|
25
|
-
|
23
|
+
const isFunction = (fn) => {
|
26
24
|
return fn && {}.toString.call(fn) === "[object Function]";
|
27
25
|
};
|
28
26
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/setRef.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/setRef.ts
|
20
18
|
var setRef_exports = {};
|
21
19
|
__export(setRef_exports, {
|
22
20
|
default: () => setRef
|
package/dist/throttle.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/throttle.ts
|
20
18
|
var throttle_exports = {};
|
21
19
|
__export(throttle_exports, {
|
22
20
|
default: () => throttle
|
@@ -28,7 +26,8 @@ function throttle(fn, interval = 200, options = { leading: true, trailing: false
|
|
28
26
|
let timer = null;
|
29
27
|
const _throttle = function(...args) {
|
30
28
|
const nowTime = (/* @__PURE__ */ new Date()).getTime();
|
31
|
-
if (!lastTime && !leading)
|
29
|
+
if (!lastTime && !leading)
|
30
|
+
lastTime = nowTime;
|
32
31
|
const remainTime = interval - (nowTime - lastTime);
|
33
32
|
if (remainTime <= 0) {
|
34
33
|
if (timer) {
|
package/dist/toArray.js
CHANGED
@@ -25,8 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
|
29
|
-
// src/toArray.ts
|
30
28
|
var toArray_exports = {};
|
31
29
|
__export(toArray_exports, {
|
32
30
|
default: () => toArray
|
package/dist/touchBlocker.js
CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/touchBlocker.ts
|
20
18
|
var touchBlocker_exports = {};
|
21
19
|
__export(touchBlocker_exports, {
|
22
20
|
default: () => blockTouch
|
@@ -36,7 +34,8 @@ function blockTouch(root) {
|
|
36
34
|
const { overflowY, overflowX } = window.getComputedStyle(el);
|
37
35
|
if (axis === "y" && (overflowY === "scroll" || overflowY === "auto")) {
|
38
36
|
const dir = moveDirection || delta;
|
39
|
-
if (moveDirection === void 0)
|
37
|
+
if (moveDirection === void 0)
|
38
|
+
moveDirection = dir;
|
40
39
|
if (el.scrollTop !== 0 && dir < 0) {
|
41
40
|
needPrevent = false;
|
42
41
|
break;
|
@@ -48,7 +47,8 @@ function blockTouch(root) {
|
|
48
47
|
}
|
49
48
|
if (axis === "x" && (overflowX === "scroll" || overflowX === "auto")) {
|
50
49
|
const dir = moveDirection || delta;
|
51
|
-
if (moveDirection === void 0)
|
50
|
+
if (moveDirection === void 0)
|
51
|
+
moveDirection = dir;
|
52
52
|
if (el.scrollLeft !== 0 && dir < 0) {
|
53
53
|
needPrevent = false;
|
54
54
|
break;
|
@@ -58,7 +58,8 @@ function blockTouch(root) {
|
|
58
58
|
break;
|
59
59
|
}
|
60
60
|
}
|
61
|
-
if (el === root)
|
61
|
+
if (el === root)
|
62
|
+
break;
|
62
63
|
el = el.parentNode;
|
63
64
|
}
|
64
65
|
return needPrevent;
|
package/dist/transitions.js
CHANGED
@@ -1,7 +1,24 @@
|
|
1
1
|
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
3
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10
|
+
var __spreadValues = (a, b) => {
|
11
|
+
for (var prop in b || (b = {}))
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
14
|
+
if (__getOwnPropSymbols)
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
16
|
+
if (__propIsEnum.call(b, prop))
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
18
|
+
}
|
19
|
+
return a;
|
20
|
+
};
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
5
22
|
var __export = (target, all) => {
|
6
23
|
for (var name in all)
|
7
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -15,8 +32,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
32
|
return to;
|
16
33
|
};
|
17
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
|
19
|
-
// src/transitions.ts
|
20
35
|
var transitions_exports = {};
|
21
36
|
__export(transitions_exports, {
|
22
37
|
createTransitions: () => createTransitions,
|
@@ -25,13 +40,13 @@ __export(transitions_exports, {
|
|
25
40
|
getTransitionProps: () => getTransitionProps
|
26
41
|
});
|
27
42
|
module.exports = __toCommonJS(transitions_exports);
|
28
|
-
|
43
|
+
const easing = {
|
29
44
|
easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
|
30
45
|
easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
|
31
46
|
easeIn: "cubic-bezier(0.4, 0, 1, 1)",
|
32
47
|
sharp: "cubic-bezier(0.4, 0, 0.6, 1)"
|
33
48
|
};
|
34
|
-
|
49
|
+
const duration = {
|
35
50
|
shortest: 150,
|
36
51
|
shorter: 200,
|
37
52
|
short: 250,
|
@@ -43,28 +58,23 @@ var duration = {
|
|
43
58
|
leavingScreen: 195
|
44
59
|
};
|
45
60
|
function getTransitionProps(props, options) {
|
61
|
+
var _a, _b, _c;
|
46
62
|
const { timeout, easing: easingProps, style = {}, delay } = props;
|
47
63
|
let { mode } = options;
|
48
64
|
if (mode !== "enter" && mode !== "exit")
|
49
65
|
mode = mode === "entering" || mode === "entered" ? "enter" : "exit";
|
50
66
|
return {
|
51
|
-
duration: style.transitionDuration
|
52
|
-
easing: style.transitionTimingFunction
|
53
|
-
delay: style.transitionDelay
|
67
|
+
duration: (_a = style.transitionDuration) != null ? _a : typeof timeout === "number" ? timeout : timeout[mode] || 0,
|
68
|
+
easing: (_b = style.transitionTimingFunction) != null ? _b : typeof easingProps === "object" ? easingProps[mode] : easingProps,
|
69
|
+
delay: (_c = style.transitionDelay) != null ? _c : typeof delay === "number" ? delay : delay[mode] || 0
|
54
70
|
};
|
55
71
|
}
|
56
72
|
function formatMs(milliseconds) {
|
57
73
|
return `${Math.round(milliseconds)}ms`;
|
58
74
|
}
|
59
75
|
function createTransitions(inputTransitions = {}) {
|
60
|
-
const mergedEasing = {
|
61
|
-
|
62
|
-
...inputTransitions.easing
|
63
|
-
};
|
64
|
-
const mergedDuration = {
|
65
|
-
...duration,
|
66
|
-
...inputTransitions.duration
|
67
|
-
};
|
76
|
+
const mergedEasing = __spreadValues(__spreadValues({}, easing), inputTransitions.easing);
|
77
|
+
const mergedDuration = __spreadValues(__spreadValues({}, duration), inputTransitions.duration);
|
68
78
|
const create = (props = ["all"], options) => {
|
69
79
|
const {
|
70
80
|
duration: durationOption = mergedDuration.standard,
|
@@ -75,12 +85,12 @@ function createTransitions(inputTransitions = {}) {
|
|
75
85
|
(animatedProp) => `${animatedProp} ${typeof durationOption === "string" ? durationOption : formatMs(durationOption)} ${easingOption} ${typeof delay === "string" ? delay : formatMs(delay)}`
|
76
86
|
).join(",");
|
77
87
|
};
|
78
|
-
return {
|
79
|
-
create
|
80
|
-
|
88
|
+
return __spreadProps(__spreadValues({
|
89
|
+
create
|
90
|
+
}, inputTransitions), {
|
81
91
|
easing: mergedEasing,
|
82
92
|
duration: mergedDuration
|
83
|
-
};
|
93
|
+
});
|
84
94
|
}
|
85
95
|
// Annotate the CommonJS export names for ESM import in node:
|
86
96
|
0 && (module.exports = {
|
package/es/debounce.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return function
|
4
|
-
|
5
|
-
|
6
|
-
args[_key] = arguments[_key];
|
7
|
-
}
|
8
|
-
if (immediate && !timeout) func.apply(this, args);
|
1
|
+
function debounce(func, wait, immediate) {
|
2
|
+
let timeout;
|
3
|
+
return function(...args) {
|
4
|
+
if (immediate && !timeout)
|
5
|
+
func.apply(this, args);
|
9
6
|
clearTimeout(timeout);
|
10
|
-
timeout = setTimeout(
|
7
|
+
timeout = setTimeout(() => {
|
11
8
|
timeout = null;
|
12
|
-
if (!immediate)
|
9
|
+
if (!immediate)
|
10
|
+
func.apply(this, args);
|
13
11
|
}, wait);
|
14
12
|
};
|
15
|
-
}
|
13
|
+
}
|
14
|
+
export {
|
15
|
+
debounce as default
|
16
|
+
};
|
package/es/domTarget.js
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
|
1
|
+
function getTargetElement(target, defaultElement) {
|
2
2
|
if (!target) {
|
3
3
|
return defaultElement;
|
4
4
|
}
|
5
|
-
|
6
|
-
if (typeof target ===
|
5
|
+
let targetElement;
|
6
|
+
if (typeof target === "function") {
|
7
7
|
targetElement = target();
|
8
|
-
} else if (
|
8
|
+
} else if ("current" in target) {
|
9
9
|
targetElement = target.current;
|
10
10
|
} else {
|
11
11
|
targetElement = target;
|
12
12
|
}
|
13
13
|
return targetElement;
|
14
|
-
}
|
14
|
+
}
|
15
|
+
export {
|
16
|
+
getTargetElement
|
17
|
+
};
|
@@ -1,17 +1,12 @@
|
|
1
|
-
|
2
|
-
function
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
|
-
import Taro from '@tarojs/taro';
|
8
|
-
export default function getBoundingClientRect(ele) {
|
9
|
-
return new Promise(function (resolve) {
|
10
|
-
var query = Taro.createSelectorQuery();
|
11
|
-
query.select("#".concat(ele.uid)).boundingClientRect().exec(function (_ref) {
|
12
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
13
|
-
res = _ref2[0];
|
1
|
+
import Taro from "@tarojs/taro";
|
2
|
+
function getBoundingClientRect(ele) {
|
3
|
+
return new Promise((resolve) => {
|
4
|
+
const query = Taro.createSelectorQuery();
|
5
|
+
query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
|
14
6
|
resolve(res);
|
15
7
|
});
|
16
8
|
});
|
17
|
-
}
|
9
|
+
}
|
10
|
+
export {
|
11
|
+
getBoundingClientRect as default
|
12
|
+
};
|
package/es/hex2rgba.js
CHANGED
@@ -1,25 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* @Date: 2021-12-30 20:30:48
|
4
|
-
* @LastEditors: @跃知
|
5
|
-
* @LastEditTime: 2021-12-30 20:35:26
|
6
|
-
* @Description: 颜色处理
|
7
|
-
*/
|
8
|
-
var convertHexToRGBA = function convertHexToRGBA(hexCode) {
|
9
|
-
var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
10
|
-
var hex = hexCode.replace('#', '');
|
1
|
+
const convertHexToRGBA = (hexCode, opacity = 1) => {
|
2
|
+
let hex = hexCode.replace("#", "");
|
11
3
|
if (hex.length === 3) {
|
12
|
-
hex =
|
4
|
+
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
|
13
5
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
/* Backward compatibility for whole number based opacity values. */
|
6
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
7
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
8
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
9
|
+
let a = opacity;
|
20
10
|
if (opacity > 1 && opacity <= 100) {
|
21
11
|
a = opacity / 100;
|
22
12
|
}
|
23
|
-
return
|
13
|
+
return `rgba(${r},${g},${b},${a})`;
|
14
|
+
};
|
15
|
+
var hex2rgba_default = convertHexToRGBA;
|
16
|
+
export {
|
17
|
+
hex2rgba_default as default
|
24
18
|
};
|
25
|
-
export default convertHexToRGBA;
|