@threekit-tools/treble 0.0.85-next-5 → 0.0.86
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/dist/components/BreatheAnimation/index.d.ts +1 -1
- package/dist/components/BreatheAnimation/index.js +11 -13
- package/dist/components/DraggableHint/index.js +6 -3
- package/dist/components/TurntableAnimation/index.d.ts +1 -1
- package/dist/components/TurntableAnimation/index.js +12 -17
- package/dist/hooks/useProductCache/index.d.ts +2 -5
- package/dist/hooks/useProductCache/index.js +2 -2
- package/package.json +1 -1
|
@@ -39,7 +39,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.BreatheAnimation = void 0;
|
|
43
42
|
var react_1 = require("react");
|
|
44
43
|
var useAnimationStart_1 = __importDefault(require("../../hooks/useAnimationStart"));
|
|
45
44
|
var types_1 = require("../../types");
|
|
@@ -51,12 +50,9 @@ var BreatheAnimation = function (props) {
|
|
|
51
50
|
var animationNodeId = (0, react_1.useRef)(undefined);
|
|
52
51
|
var startTime = (0, react_1.useRef)(null);
|
|
53
52
|
var timeoutId = (0, react_1.useRef)(null);
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
resumeDelay: undefined,
|
|
58
|
-
nodeName: undefined,
|
|
59
|
-
}, props), speed = _a.speed, magnifier = _a.magnifier, resumeDelay = _a.resumeDelay, nodeName = _a.nodeName;
|
|
53
|
+
var speed = props.speed || 4;
|
|
54
|
+
var magnifier = props.magnifier || 2;
|
|
55
|
+
var resumeDelay = props.resumeDelay, nodeName = props.nodeName;
|
|
60
56
|
(0, react_1.useEffect)(function () {
|
|
61
57
|
if (!readyToAnimate)
|
|
62
58
|
return;
|
|
@@ -141,6 +137,10 @@ var BreatheAnimation = function (props) {
|
|
|
141
137
|
animationInProgress.current = false;
|
|
142
138
|
if (resumeDelay === undefined)
|
|
143
139
|
window.threekit.player.tools.removeTool(ruleName);
|
|
140
|
+
if (timeoutId.current) {
|
|
141
|
+
clearTimeout(timeoutId.current);
|
|
142
|
+
timeoutId.current = null;
|
|
143
|
+
}
|
|
144
144
|
return [2];
|
|
145
145
|
});
|
|
146
146
|
}); },
|
|
@@ -148,10 +148,6 @@ var BreatheAnimation = function (props) {
|
|
|
148
148
|
return __generator(this, function (_a) {
|
|
149
149
|
if (resumeDelay === undefined)
|
|
150
150
|
return [2];
|
|
151
|
-
if (timeoutId.current) {
|
|
152
|
-
clearTimeout(timeoutId.current);
|
|
153
|
-
timeoutId.current = null;
|
|
154
|
-
}
|
|
155
151
|
timeoutId.current = setTimeout(function () {
|
|
156
152
|
initialRotation.current = window.threekit.player.scene.get({
|
|
157
153
|
id: animationNodeId.current,
|
|
@@ -177,8 +173,10 @@ var BreatheAnimation = function (props) {
|
|
|
177
173
|
}
|
|
178
174
|
});
|
|
179
175
|
}); })();
|
|
176
|
+
return function () {
|
|
177
|
+
window.threekit.player.tools.removeTool(ruleName);
|
|
178
|
+
};
|
|
180
179
|
}, [readyToAnimate]);
|
|
181
180
|
return null;
|
|
182
181
|
};
|
|
183
|
-
exports.
|
|
184
|
-
exports.default = exports.BreatheAnimation;
|
|
182
|
+
exports.default = BreatheAnimation;
|
|
@@ -35,9 +35,12 @@ function DraggableIndicator(props) {
|
|
|
35
35
|
var awaitingFirstInteraction = (0, useFirstPlayerInteraction_1.default)();
|
|
36
36
|
var _a = (0, react_1.useState)(false), hasTimeoutExpired = _a[0], setHasTimeoutExpired = _a[1];
|
|
37
37
|
(0, react_1.useEffect)(function () {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var timeout;
|
|
39
|
+
if (awaitingFirstInteraction && props.timeout) {
|
|
40
|
+
timeout = setTimeout(function () { return setHasTimeoutExpired(true); }, props.timeout);
|
|
41
|
+
}
|
|
42
|
+
return function () { return timeout && clearTimeout(timeout); };
|
|
43
|
+
}, [awaitingFirstInteraction, props.timeout]);
|
|
41
44
|
if (!awaitingFirstInteraction || hasTimeoutExpired)
|
|
42
45
|
return null;
|
|
43
46
|
return (react_1.default.createElement(draggableIndicator_styles_1.Wrapper, null,
|
|
@@ -8,5 +8,5 @@ interface TurntableAnimationProps {
|
|
|
8
8
|
rotationDirection?: RotationDirections;
|
|
9
9
|
nodeName: string;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
declare const TurntableAnimation: (props: TurntableAnimationProps) => null;
|
|
12
12
|
export default TurntableAnimation;
|
|
@@ -39,7 +39,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.TurntableAnimation = void 0;
|
|
43
42
|
var react_1 = require("react");
|
|
44
43
|
var useAnimationStart_1 = __importDefault(require("../../hooks/useAnimationStart"));
|
|
45
44
|
var types_1 = require("../../types");
|
|
@@ -55,12 +54,9 @@ var TurntableAnimation = function (props) {
|
|
|
55
54
|
var rotationNodeId = (0, react_1.useRef)(undefined);
|
|
56
55
|
var startTime = (0, react_1.useRef)(null);
|
|
57
56
|
var timeoutId = (0, react_1.useRef)(null);
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
rotationDirection: RotationDirections.CLOCKWISE,
|
|
62
|
-
nodeName: undefined,
|
|
63
|
-
}, props), speed = _a.speed, resumeDelay = _a.resumeDelay, rotationDirection = _a.rotationDirection, nodeName = _a.nodeName;
|
|
57
|
+
var speed = props.speed || 4;
|
|
58
|
+
var rotationDirection = props.resumeDelay || RotationDirections.CLOCKWISE;
|
|
59
|
+
var resumeDelay = props.resumeDelay, nodeName = props.nodeName;
|
|
64
60
|
(0, react_1.useEffect)(function () {
|
|
65
61
|
if (!readyToAnimate)
|
|
66
62
|
return;
|
|
@@ -125,6 +121,10 @@ var TurntableAnimation = function (props) {
|
|
|
125
121
|
animationInProgress.current = false;
|
|
126
122
|
if (resumeDelay === undefined)
|
|
127
123
|
window.threekit.player.tools.removeTool(ruleName);
|
|
124
|
+
if (timeoutId.current) {
|
|
125
|
+
clearTimeout(timeoutId.current);
|
|
126
|
+
timeoutId.current = null;
|
|
127
|
+
}
|
|
128
128
|
return [2];
|
|
129
129
|
});
|
|
130
130
|
}); },
|
|
@@ -132,10 +132,6 @@ var TurntableAnimation = function (props) {
|
|
|
132
132
|
return __generator(this, function (_a) {
|
|
133
133
|
if (resumeDelay === undefined)
|
|
134
134
|
return [2];
|
|
135
|
-
if (timeoutId.current) {
|
|
136
|
-
clearTimeout(timeoutId.current);
|
|
137
|
-
timeoutId.current = null;
|
|
138
|
-
}
|
|
139
135
|
timeoutId.current = setTimeout(function () {
|
|
140
136
|
initialRotation.current = window.threekit.player.scene.get({
|
|
141
137
|
id: rotationNodeId.current,
|
|
@@ -152,15 +148,14 @@ var TurntableAnimation = function (props) {
|
|
|
152
148
|
},
|
|
153
149
|
});
|
|
154
150
|
window.requestAnimationFrame(animateFrame);
|
|
155
|
-
return [2
|
|
156
|
-
if (resumeDelay !== undefined)
|
|
157
|
-
window.threekit.player.tools.removeTool(ruleName);
|
|
158
|
-
}];
|
|
151
|
+
return [2];
|
|
159
152
|
}
|
|
160
153
|
});
|
|
161
154
|
}); })();
|
|
155
|
+
return function () {
|
|
156
|
+
window.threekit.player.tools.removeTool(ruleName);
|
|
157
|
+
};
|
|
162
158
|
}, [readyToAnimate]);
|
|
163
159
|
return null;
|
|
164
160
|
};
|
|
165
|
-
exports.
|
|
166
|
-
exports.default = exports.TurntableAnimation;
|
|
161
|
+
exports.default = TurntableAnimation;
|
|
@@ -10,13 +10,10 @@ interface ISelectableProduct {
|
|
|
10
10
|
label: string;
|
|
11
11
|
handleSelect: (config?: LoadProductConfig) => void;
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
interface UseProductCache {
|
|
14
14
|
cache: Array<HydratedCacheProduct>;
|
|
15
15
|
products: Array<ISelectableProduct>;
|
|
16
|
+
onLoadNewProduct: (config?: string | IReloadConfig) => Promise<void>;
|
|
16
17
|
}
|
|
17
|
-
declare type UseProductCache = [
|
|
18
|
-
CacheData,
|
|
19
|
-
(config?: string | IReloadConfig) => Promise<void>
|
|
20
|
-
];
|
|
21
18
|
declare const useProductCache: () => UseProductCache;
|
|
22
19
|
export default useProductCache;
|
|
@@ -6,7 +6,7 @@ var useProductCache = function () {
|
|
|
6
6
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
7
|
var cache = (0, store_1.useThreekitSelector)(product_1.getProductCache);
|
|
8
8
|
var activeProductIdx = (0, store_1.useThreekitSelector)(product_1.getActiveCacheIdx);
|
|
9
|
-
var
|
|
9
|
+
var onLoadNewProduct = function (config) {
|
|
10
10
|
return dispatch((0, product_1.loadNewProduct)(config));
|
|
11
11
|
};
|
|
12
12
|
var hydratedCache = cache.map(function (el, i) {
|
|
@@ -25,6 +25,6 @@ var useProductCache = function () {
|
|
|
25
25
|
return dispatch((0, product_1.loadProduct)(prod, config));
|
|
26
26
|
},
|
|
27
27
|
}); });
|
|
28
|
-
return
|
|
28
|
+
return { cache: hydratedCache, products: products, onLoadNewProduct: onLoadNewProduct };
|
|
29
29
|
};
|
|
30
30
|
exports.default = useProductCache;
|