@ray-js/framework-shared 1.4.3 → 1.4.5-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/package.json +4 -4
  2. package/lib/emitter/index.android.js +0 -1
  3. package/lib/emitter/index.ios.js +0 -1
  4. package/lib/emitter/index.tuya.js +0 -57
  5. package/lib/emitter/index.web.js +0 -57
  6. package/lib/emitter/index.wechat.js +0 -57
  7. package/lib/filterProps/index.android.js +0 -1
  8. package/lib/filterProps/index.ios.js +0 -1
  9. package/lib/filterProps/index.tuya.js +0 -30
  10. package/lib/filterProps/index.web.js +0 -30
  11. package/lib/filterProps/index.wechat.js +0 -30
  12. package/lib/index.android.js +0 -1
  13. package/lib/index.ios.js +0 -1
  14. package/lib/index.tuya.js +0 -9
  15. package/lib/index.web.js +0 -9
  16. package/lib/index.wechat.js +0 -9
  17. package/lib/inlineStyle/CSSProperty.android.js +0 -1
  18. package/lib/inlineStyle/CSSProperty.ios.js +0 -1
  19. package/lib/inlineStyle/CSSProperty.tuya.js +0 -78
  20. package/lib/inlineStyle/CSSProperty.web.js +0 -78
  21. package/lib/inlineStyle/CSSProperty.wechat.js +0 -78
  22. package/lib/inlineStyle/index.android.js +0 -1
  23. package/lib/inlineStyle/index.ios.js +0 -1
  24. package/lib/inlineStyle/index.tuya.js +0 -49
  25. package/lib/inlineStyle/index.web.js +0 -49
  26. package/lib/inlineStyle/index.wechat.js +0 -49
  27. package/lib/plainStyle/index.android.js +0 -1
  28. package/lib/plainStyle/index.ios.js +0 -1
  29. package/lib/plainStyle/index.tuya.js +0 -52
  30. package/lib/plainStyle/index.web.js +0 -52
  31. package/lib/plainStyle/index.wechat.js +0 -52
  32. package/lib/useInterval/index.android.js +0 -1
  33. package/lib/useInterval/index.ios.js +0 -1
  34. package/lib/useInterval/index.tuya.js +0 -24
  35. package/lib/useInterval/index.web.js +0 -24
  36. package/lib/useInterval/index.wechat.js +0 -24
  37. package/lib/useStylesheet/index.android.js +0 -1
  38. package/lib/useStylesheet/index.ios.js +0 -1
  39. package/lib/useStylesheet/index.tuya.js +0 -24
  40. package/lib/useStylesheet/index.web.js +0 -24
  41. package/lib/useStylesheet/index.wechat.js +0 -24
  42. package/lib/useThrottle/index.android.js +0 -1
  43. package/lib/useThrottle/index.ios.js +0 -1
  44. package/lib/useThrottle/index.tuya.js +0 -36
  45. package/lib/useThrottle/index.web.js +0 -36
  46. package/lib/useThrottle/index.wechat.js +0 -36
  47. package/lib/useTouch/index.android.js +0 -1
  48. package/lib/useTouch/index.d.ts +0 -43
  49. package/lib/useTouch/index.ios.js +0 -1
  50. package/lib/useTouch/index.tuya.js +0 -125
  51. package/lib/useTouch/index.web.js +0 -137
  52. package/lib/useTouch/index.wechat.js +0 -125
  53. package/lib/useTransition/index.android.js +0 -1
  54. package/lib/useTransition/index.ios.js +0 -1
  55. package/lib/useTransition/index.tuya.js +0 -53
  56. package/lib/useTransition/index.web.js +0 -53
  57. package/lib/useTransition/index.wechat.js +0 -53
@@ -1,125 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import "core-js/modules/es.array.filter.js";
4
- import "core-js/modules/es.object.to-string.js";
5
- import "core-js/modules/es.array.map.js";
6
- import "core-js/modules/web.dom-collections.for-each.js";
7
- import * as React from 'react';
8
- var isMiniProgram = true;
9
- var isWechat = false;
10
- var isWeb = false;
11
- var LONG_TAP_DURATION = 350;
12
- export function useTouch(_ref) {
13
- var hoverDuration = _ref.hoverDuration,
14
- hoverDelay = _ref.hoverDelay,
15
- onLongClick = _ref.onLongClick,
16
- onTouchCancel = _ref.onTouchCancel,
17
- onTouchEnd = _ref.onTouchEnd,
18
- onTouchMove = _ref.onTouchMove,
19
- onTouchStart = _ref.onTouchStart,
20
- onClick = _ref.onClick;
21
-
22
- var _React$useState = React.useState(false),
23
- _React$useState2 = _slicedToArray(_React$useState, 2),
24
- touching = _React$useState2[0],
25
- setTouching = _React$useState2[1];
26
-
27
- var hoveringRef = React.useRef(false);
28
- var timers = React.useRef([]);
29
-
30
- function executeTimeout(callback, time) {
31
- var timer = setTimeout(function () {
32
- callback();
33
- timers.current.filter(function (t) {
34
- return t !== timer;
35
- });
36
- }, time);
37
- timers.current.push(timer);
38
- }
39
-
40
- function formatTouches(touchs) {
41
- if (Array.isArray(touchs)) {
42
- return touchs && touchs.map(function (item) {
43
- return {
44
- identifier: item.identifier,
45
- pageX: item.pageX,
46
- pageY: item.pageY
47
- };
48
- });
49
- } else {
50
- return [_objectSpread({}, touchs)];
51
- }
52
- }
53
-
54
- function formatRayEvent(e, touchType) {
55
- return {
56
- type: (e === null || e === void 0 ? void 0 : e.type) || touchType || '',
57
- touches: formatTouches(e.touches),
58
- changedTouches: formatTouches(e.changedTouches),
59
- timeStamp: e.timeStamp || e.timestamp,
60
- origin: e
61
- };
62
- }
63
-
64
- function formatRayClickEvent(e, clickType) {
65
- return {
66
- type: (e === null || e === void 0 ? void 0 : e.type) || clickType || '',
67
- timeStamp: e.timeStamp,
68
- pageX: e.pageX,
69
- pageY: e.pageY,
70
- origin: e
71
- };
72
- }
73
-
74
- React.useEffect(function () {
75
- return function () {
76
- timers.current.forEach(function (t) {
77
- return clearTimeout(t);
78
- });
79
- };
80
- }, []);
81
- return [touching, {
82
- onTouchStart: function (e) {
83
- hoveringRef.current = true;
84
- executeTimeout(function () {
85
- if (hoveringRef.current) {
86
- setTouching(true);
87
- }
88
- }, hoverDelay);
89
- return onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(formatRayEvent(e, 'touchstart'));
90
- },
91
- onTouchMove: function (e) {
92
- hoveringRef.current = false;
93
- executeTimeout(function () {
94
- if (touching) {
95
- setTouching(false);
96
- }
97
- }, hoverDuration);
98
- return onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(formatRayEvent(e, 'touchmove'));
99
- },
100
- onTouchEnd: function (e) {
101
- hoveringRef.current = false;
102
- executeTimeout(function () {
103
- if (touching) {
104
- setTouching(false);
105
- }
106
- }, hoverDuration);
107
- return onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(formatRayEvent(e, 'touchend'));
108
- },
109
- onTouchCancel: function (e) {
110
- hoveringRef.current = false;
111
- executeTimeout(function () {
112
- if (touching) {
113
- setTouching(false);
114
- }
115
- }, hoverDuration);
116
- return onTouchCancel === null || onTouchCancel === void 0 ? void 0 : onTouchCancel(formatRayEvent(e, 'touchcancel'));
117
- },
118
- onClick: function (e) {
119
- return onClick === null || onClick === void 0 ? void 0 : onClick(formatRayClickEvent(e, 'click'));
120
- },
121
- onLongClick: function (e) {
122
- return onLongClick === null || onLongClick === void 0 ? void 0 : onLongClick(formatRayClickEvent(e, 'longclick'));
123
- }
124
- }];
125
- }
@@ -1,137 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import "core-js/modules/es.array.filter.js";
4
- import "core-js/modules/es.object.to-string.js";
5
- import "core-js/modules/es.array.map.js";
6
- import "core-js/modules/web.dom-collections.for-each.js";
7
- import * as React from 'react';
8
- var isMiniProgram = false;
9
- var isWechat = false;
10
- var isWeb = true;
11
- var LONG_TAP_DURATION = 350;
12
- export function useTouch(_ref) {
13
- var hoverDuration = _ref.hoverDuration,
14
- hoverDelay = _ref.hoverDelay,
15
- onLongClick = _ref.onLongClick,
16
- onTouchCancel = _ref.onTouchCancel,
17
- onTouchEnd = _ref.onTouchEnd,
18
- onTouchMove = _ref.onTouchMove,
19
- onTouchStart = _ref.onTouchStart,
20
- onClick = _ref.onClick;
21
-
22
- var _React$useState = React.useState(false),
23
- _React$useState2 = _slicedToArray(_React$useState, 2),
24
- touching = _React$useState2[0],
25
- setTouching = _React$useState2[1];
26
-
27
- var hoveringRef = React.useRef(false);
28
- var timers = React.useRef([]);
29
-
30
- function executeTimeout(callback, time) {
31
- var timer = setTimeout(function () {
32
- callback();
33
- timers.current.filter(function (t) {
34
- return t !== timer;
35
- });
36
- }, time);
37
- timers.current.push(timer);
38
- }
39
-
40
- function formatTouches(touchs) {
41
- if (Array.isArray(touchs)) {
42
- return touchs && touchs.map(function (item) {
43
- return {
44
- identifier: item.identifier,
45
- pageX: item.pageX,
46
- pageY: item.pageY
47
- };
48
- });
49
- } else {
50
- return [_objectSpread({}, touchs)];
51
- }
52
- }
53
-
54
- function formatRayEvent(e, touchType) {
55
- return {
56
- type: (e === null || e === void 0 ? void 0 : e.type) || touchType || '',
57
- touches: formatTouches(e.touches),
58
- changedTouches: formatTouches(e.changedTouches),
59
- timeStamp: e.timeStamp || e.timestamp,
60
- origin: e
61
- };
62
- }
63
-
64
- function formatRayClickEvent(e, clickType) {
65
- return {
66
- type: (e === null || e === void 0 ? void 0 : e.type) || clickType || '',
67
- timeStamp: e.timeStamp,
68
- pageX: e.pageX,
69
- pageY: e.pageY,
70
- origin: e
71
- };
72
- }
73
-
74
- React.useEffect(function () {
75
- return function () {
76
- timers.current.forEach(function (t) {
77
- return clearTimeout(t);
78
- });
79
- };
80
- }, []);
81
-
82
- function handleLongClick(e) {
83
- return onLongClick === null || onLongClick === void 0 ? void 0 : onLongClick(formatRayClickEvent(e, 'longclick'));
84
- }
85
-
86
- return [touching, {
87
- onTouchStart: function (e) {
88
- hoveringRef.current = true;
89
- executeTimeout(function () {
90
- if (hoveringRef.current) {
91
- setTouching(true);
92
- }
93
- }, hoverDelay);
94
-
95
- if (typeof onLongClick === 'function') {
96
- executeTimeout(function () {
97
- if (hoveringRef.current) {
98
- handleLongClick(e);
99
- }
100
- }, LONG_TAP_DURATION);
101
- }
102
-
103
- return onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(formatRayEvent(e, 'touchstart'));
104
- },
105
- onTouchMove: function (e) {
106
- hoveringRef.current = false;
107
- executeTimeout(function () {
108
- if (touching) {
109
- setTouching(false);
110
- }
111
- }, hoverDuration);
112
- return onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(formatRayEvent(e, 'touchmove'));
113
- },
114
- onTouchEnd: function (e) {
115
- hoveringRef.current = false;
116
- executeTimeout(function () {
117
- if (touching) {
118
- setTouching(false);
119
- }
120
- }, hoverDuration);
121
- return onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(formatRayEvent(e, 'touchend'));
122
- },
123
- onTouchCancel: function (e) {
124
- hoveringRef.current = false;
125
- executeTimeout(function () {
126
- if (touching) {
127
- setTouching(false);
128
- }
129
- }, hoverDuration);
130
- return onTouchCancel === null || onTouchCancel === void 0 ? void 0 : onTouchCancel(formatRayEvent(e, 'touchcancel'));
131
- },
132
- onClick: function (e) {
133
- return onClick === null || onClick === void 0 ? void 0 : onClick(formatRayClickEvent(e, 'click'));
134
- },
135
- onLongClick: handleLongClick
136
- }];
137
- }
@@ -1,125 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import "core-js/modules/es.array.filter.js";
4
- import "core-js/modules/es.object.to-string.js";
5
- import "core-js/modules/es.array.map.js";
6
- import "core-js/modules/web.dom-collections.for-each.js";
7
- import * as React from 'react';
8
- var isMiniProgram = true;
9
- var isWechat = true;
10
- var isWeb = false;
11
- var LONG_TAP_DURATION = 350;
12
- export function useTouch(_ref) {
13
- var hoverDuration = _ref.hoverDuration,
14
- hoverDelay = _ref.hoverDelay,
15
- onLongClick = _ref.onLongClick,
16
- onTouchCancel = _ref.onTouchCancel,
17
- onTouchEnd = _ref.onTouchEnd,
18
- onTouchMove = _ref.onTouchMove,
19
- onTouchStart = _ref.onTouchStart,
20
- onClick = _ref.onClick;
21
-
22
- var _React$useState = React.useState(false),
23
- _React$useState2 = _slicedToArray(_React$useState, 2),
24
- touching = _React$useState2[0],
25
- setTouching = _React$useState2[1];
26
-
27
- var hoveringRef = React.useRef(false);
28
- var timers = React.useRef([]);
29
-
30
- function executeTimeout(callback, time) {
31
- var timer = setTimeout(function () {
32
- callback();
33
- timers.current.filter(function (t) {
34
- return t !== timer;
35
- });
36
- }, time);
37
- timers.current.push(timer);
38
- }
39
-
40
- function formatTouches(touchs) {
41
- if (Array.isArray(touchs)) {
42
- return touchs && touchs.map(function (item) {
43
- return {
44
- identifier: item.identifier,
45
- pageX: item.pageX,
46
- pageY: item.pageY
47
- };
48
- });
49
- } else {
50
- return [_objectSpread({}, touchs)];
51
- }
52
- }
53
-
54
- function formatRayEvent(e, touchType) {
55
- return {
56
- type: (e === null || e === void 0 ? void 0 : e.type) || touchType || '',
57
- touches: formatTouches(e.touches),
58
- changedTouches: formatTouches(e.changedTouches),
59
- timeStamp: e.timeStamp || e.timestamp,
60
- origin: e
61
- };
62
- }
63
-
64
- function formatRayClickEvent(e, clickType) {
65
- return {
66
- type: (e === null || e === void 0 ? void 0 : e.type) || clickType || '',
67
- timeStamp: e.timeStamp,
68
- pageX: e.pageX,
69
- pageY: e.pageY,
70
- origin: e
71
- };
72
- }
73
-
74
- React.useEffect(function () {
75
- return function () {
76
- timers.current.forEach(function (t) {
77
- return clearTimeout(t);
78
- });
79
- };
80
- }, []);
81
- return [touching, {
82
- onTouchStart: function (e) {
83
- hoveringRef.current = true;
84
- executeTimeout(function () {
85
- if (hoveringRef.current) {
86
- setTouching(true);
87
- }
88
- }, hoverDelay);
89
- return onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(formatRayEvent(e, 'touchstart'));
90
- },
91
- onTouchMove: function (e) {
92
- hoveringRef.current = false;
93
- executeTimeout(function () {
94
- if (touching) {
95
- setTouching(false);
96
- }
97
- }, hoverDuration);
98
- return onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(formatRayEvent(e, 'touchmove'));
99
- },
100
- onTouchEnd: function (e) {
101
- hoveringRef.current = false;
102
- executeTimeout(function () {
103
- if (touching) {
104
- setTouching(false);
105
- }
106
- }, hoverDuration);
107
- return onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(formatRayEvent(e, 'touchend'));
108
- },
109
- onTouchCancel: function (e) {
110
- hoveringRef.current = false;
111
- executeTimeout(function () {
112
- if (touching) {
113
- setTouching(false);
114
- }
115
- }, hoverDuration);
116
- return onTouchCancel === null || onTouchCancel === void 0 ? void 0 : onTouchCancel(formatRayEvent(e, 'touchcancel'));
117
- },
118
- onClick: function (e) {
119
- return onClick === null || onClick === void 0 ? void 0 : onClick(formatRayClickEvent(e, 'click'));
120
- },
121
- onLongClick: function (e) {
122
- return onLongClick === null || onLongClick === void 0 ? void 0 : onLongClick(formatRayClickEvent(e, 'longclick'));
123
- }
124
- }];
125
- }
@@ -1 +0,0 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useTransition=useTransition;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var nextFrame=function(){var duration=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1000/30;return new Promise(function(resolve){return setTimeout(resolve,duration);});};function useTransition(options,deps){var _options$duration=options.duration,duration=_options$duration===void 0?200:_options$duration,onFinish=options.onFinish,onStart=options.onStart;var _deps=(0,_slicedToArray2.default)(deps,1),_deps$=_deps[0],visible=_deps$===void 0?false:_deps$;var showRef=(0,_react.useRef)(visible);var _useState=(0,_react.useState)(visible?'showComplete':'hideComplete'),_useState2=(0,_slicedToArray2.default)(_useState,2),status=_useState2[0],setStatus=_useState2[1];function updateShow(show){if(showRef.current===show)return false;showRef.current=show;onStart===null||onStart===void 0?void 0:onStart(showRef.current);setStatus(showRef.current?'showStart':'hideStart');nextFrame(duration).then(function(){setStatus(showRef.current?'showComplete':'hideComplete');onFinish===null||onFinish===void 0?void 0:onFinish(showRef.current);});}(0,_react.useEffect)(function(){updateShow(visible);},[visible]);return[status,{animationDuration:duration/1000+"s"},updateShow];}
@@ -1 +0,0 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useTransition=useTransition;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=require("react");var nextFrame=function(){var duration=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1000/30;return new Promise(function(resolve){return setTimeout(resolve,duration);});};function useTransition(options,deps){var _options$duration=options.duration,duration=_options$duration===void 0?200:_options$duration,onFinish=options.onFinish,onStart=options.onStart;var _deps=(0,_slicedToArray2.default)(deps,1),_deps$=_deps[0],visible=_deps$===void 0?false:_deps$;var showRef=(0,_react.useRef)(visible);var _useState=(0,_react.useState)(visible?'showComplete':'hideComplete'),_useState2=(0,_slicedToArray2.default)(_useState,2),status=_useState2[0],setStatus=_useState2[1];function updateShow(show){if(showRef.current===show)return false;showRef.current=show;onStart===null||onStart===void 0?void 0:onStart(showRef.current);setStatus(showRef.current?'showStart':'hideStart');nextFrame(duration).then(function(){setStatus(showRef.current?'showComplete':'hideComplete');onFinish===null||onFinish===void 0?void 0:onFinish(showRef.current);});}(0,_react.useEffect)(function(){updateShow(visible);},[visible]);return[status,{animationDuration:duration/1000+"s"},updateShow];}
@@ -1,53 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import "core-js/modules/es.object.to-string.js";
3
- import "core-js/modules/es.promise.js";
4
- import { useEffect, useRef, useState } from 'react';
5
-
6
- var nextFrame = function () {
7
- var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000 / 30;
8
- return new Promise(function (resolve) {
9
- return setTimeout(resolve, duration);
10
- });
11
- };
12
- /**
13
- * 用于执行动画的时序管理
14
- * @param options transition 选项
15
- * @param visible 是否可见
16
- */
17
-
18
-
19
- export function useTransition(options, deps) {
20
- var _options$duration = options.duration,
21
- duration = _options$duration === void 0 ? 200 : _options$duration,
22
- onFinish = options.onFinish,
23
- onStart = options.onStart;
24
-
25
- var _deps = _slicedToArray(deps, 1),
26
- _deps$ = _deps[0],
27
- visible = _deps$ === void 0 ? false : _deps$;
28
-
29
- var showRef = useRef(visible);
30
-
31
- var _useState = useState(visible ? 'showComplete' : 'hideComplete'),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- status = _useState2[0],
34
- setStatus = _useState2[1];
35
-
36
- function updateShow(show) {
37
- if (showRef.current === show) return false;
38
- showRef.current = show;
39
- onStart === null || onStart === void 0 ? void 0 : onStart(showRef.current);
40
- setStatus(showRef.current ? 'showStart' : 'hideStart');
41
- nextFrame(duration).then(function () {
42
- setStatus(showRef.current ? 'showComplete' : 'hideComplete');
43
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(showRef.current);
44
- });
45
- }
46
-
47
- useEffect(function () {
48
- updateShow(visible);
49
- }, [visible]);
50
- return [status, {
51
- animationDuration: "".concat(duration / 1000, "s")
52
- }, updateShow];
53
- }
@@ -1,53 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import "core-js/modules/es.object.to-string.js";
3
- import "core-js/modules/es.promise.js";
4
- import { useEffect, useRef, useState } from 'react';
5
-
6
- var nextFrame = function () {
7
- var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000 / 30;
8
- return new Promise(function (resolve) {
9
- return setTimeout(resolve, duration);
10
- });
11
- };
12
- /**
13
- * 用于执行动画的时序管理
14
- * @param options transition 选项
15
- * @param visible 是否可见
16
- */
17
-
18
-
19
- export function useTransition(options, deps) {
20
- var _options$duration = options.duration,
21
- duration = _options$duration === void 0 ? 200 : _options$duration,
22
- onFinish = options.onFinish,
23
- onStart = options.onStart;
24
-
25
- var _deps = _slicedToArray(deps, 1),
26
- _deps$ = _deps[0],
27
- visible = _deps$ === void 0 ? false : _deps$;
28
-
29
- var showRef = useRef(visible);
30
-
31
- var _useState = useState(visible ? 'showComplete' : 'hideComplete'),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- status = _useState2[0],
34
- setStatus = _useState2[1];
35
-
36
- function updateShow(show) {
37
- if (showRef.current === show) return false;
38
- showRef.current = show;
39
- onStart === null || onStart === void 0 ? void 0 : onStart(showRef.current);
40
- setStatus(showRef.current ? 'showStart' : 'hideStart');
41
- nextFrame(duration).then(function () {
42
- setStatus(showRef.current ? 'showComplete' : 'hideComplete');
43
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(showRef.current);
44
- });
45
- }
46
-
47
- useEffect(function () {
48
- updateShow(visible);
49
- }, [visible]);
50
- return [status, {
51
- animationDuration: "".concat(duration / 1000, "s")
52
- }, updateShow];
53
- }
@@ -1,53 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import "core-js/modules/es.object.to-string.js";
3
- import "core-js/modules/es.promise.js";
4
- import { useEffect, useRef, useState } from 'react';
5
-
6
- var nextFrame = function () {
7
- var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000 / 30;
8
- return new Promise(function (resolve) {
9
- return setTimeout(resolve, duration);
10
- });
11
- };
12
- /**
13
- * 用于执行动画的时序管理
14
- * @param options transition 选项
15
- * @param visible 是否可见
16
- */
17
-
18
-
19
- export function useTransition(options, deps) {
20
- var _options$duration = options.duration,
21
- duration = _options$duration === void 0 ? 200 : _options$duration,
22
- onFinish = options.onFinish,
23
- onStart = options.onStart;
24
-
25
- var _deps = _slicedToArray(deps, 1),
26
- _deps$ = _deps[0],
27
- visible = _deps$ === void 0 ? false : _deps$;
28
-
29
- var showRef = useRef(visible);
30
-
31
- var _useState = useState(visible ? 'showComplete' : 'hideComplete'),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- status = _useState2[0],
34
- setStatus = _useState2[1];
35
-
36
- function updateShow(show) {
37
- if (showRef.current === show) return false;
38
- showRef.current = show;
39
- onStart === null || onStart === void 0 ? void 0 : onStart(showRef.current);
40
- setStatus(showRef.current ? 'showStart' : 'hideStart');
41
- nextFrame(duration).then(function () {
42
- setStatus(showRef.current ? 'showComplete' : 'hideComplete');
43
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(showRef.current);
44
- });
45
- }
46
-
47
- useEffect(function () {
48
- updateShow(visible);
49
- }, [visible]);
50
- return [status, {
51
- animationDuration: "".concat(duration / 1000, "s")
52
- }, updateShow];
53
- }