@primestyleai/tryon 3.6.5 → 3.6.6
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/react/index.js +26 -7
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -261,11 +261,11 @@ function PrimeStyleTryonInner({
|
|
|
261
261
|
const progressBarRef = useRef(null);
|
|
262
262
|
const progressTextRef = useRef(null);
|
|
263
263
|
const progressStatusRef = useRef(null);
|
|
264
|
+
const progressIntervalRef = useRef(null);
|
|
264
265
|
useEffect(() => {
|
|
265
266
|
if (view === "processing") {
|
|
267
|
+
if (progressIntervalRef.current) return;
|
|
266
268
|
progressRef.current = 0;
|
|
267
|
-
if (progressBarRef.current) progressBarRef.current.style.width = "0%";
|
|
268
|
-
if (progressTextRef.current) progressTextRef.current.textContent = "0%";
|
|
269
269
|
const statuses = [
|
|
270
270
|
{ at: 0, text: "Preparing your image..." },
|
|
271
271
|
{ at: 15, text: "Analyzing body proportions..." },
|
|
@@ -274,7 +274,7 @@ function PrimeStyleTryonInner({
|
|
|
274
274
|
{ at: 75, text: "Refining details..." },
|
|
275
275
|
{ at: 90, text: "Almost there..." }
|
|
276
276
|
];
|
|
277
|
-
|
|
277
|
+
progressIntervalRef.current = setInterval(() => {
|
|
278
278
|
const p = progressRef.current;
|
|
279
279
|
if (p >= 100) return;
|
|
280
280
|
const increment = p < 30 ? 1.2 : p < 60 ? 0.8 : p < 80 ? 0.4 : p < 95 ? 0.15 : 0;
|
|
@@ -287,7 +287,15 @@ function PrimeStyleTryonInner({
|
|
|
287
287
|
if (status) progressStatusRef.current.textContent = status.text;
|
|
288
288
|
}
|
|
289
289
|
}, 200);
|
|
290
|
-
return () =>
|
|
290
|
+
return () => {
|
|
291
|
+
clearInterval(progressIntervalRef.current);
|
|
292
|
+
progressIntervalRef.current = null;
|
|
293
|
+
};
|
|
294
|
+
} else {
|
|
295
|
+
if (progressIntervalRef.current) {
|
|
296
|
+
clearInterval(progressIntervalRef.current);
|
|
297
|
+
progressIntervalRef.current = null;
|
|
298
|
+
}
|
|
291
299
|
}
|
|
292
300
|
}, [view]);
|
|
293
301
|
useEffect(() => {
|
|
@@ -1071,6 +1079,17 @@ function PrimeStyleTryonInner({
|
|
|
1071
1079
|
] }, `form-${formGender}-${sizingUnit}-${heightUnit}-${sizingCountry}-${formKey}`);
|
|
1072
1080
|
}
|
|
1073
1081
|
function ProcessingView() {
|
|
1082
|
+
const barCb = useCallback((el) => {
|
|
1083
|
+
progressBarRef.current = el;
|
|
1084
|
+
if (el) el.style.width = `${Math.round(progressRef.current)}%`;
|
|
1085
|
+
}, []);
|
|
1086
|
+
const pctCb = useCallback((el) => {
|
|
1087
|
+
progressTextRef.current = el;
|
|
1088
|
+
if (el) el.textContent = `${Math.round(progressRef.current)}%`;
|
|
1089
|
+
}, []);
|
|
1090
|
+
const statusCb = useCallback((el) => {
|
|
1091
|
+
progressStatusRef.current = el;
|
|
1092
|
+
}, []);
|
|
1074
1093
|
return /* @__PURE__ */ jsxs("div", { className: "ps-tryon-processing", children: [
|
|
1075
1094
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-processing-image-wrap", children: [
|
|
1076
1095
|
previewUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1081,10 +1100,10 @@ function PrimeStyleTryonInner({
|
|
|
1081
1100
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-scan-overlay" })
|
|
1082
1101
|
] }),
|
|
1083
1102
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-progress-section", children: [
|
|
1084
|
-
/* @__PURE__ */ jsx("div", { className: "ps-tryon-progress-bar-wrap", children: /* @__PURE__ */ jsx("div", { ref:
|
|
1085
|
-
/* @__PURE__ */ jsx("span", { ref:
|
|
1103
|
+
/* @__PURE__ */ jsx("div", { className: "ps-tryon-progress-bar-wrap", children: /* @__PURE__ */ jsx("div", { ref: barCb, className: "ps-tryon-progress-bar-fill" }) }),
|
|
1104
|
+
/* @__PURE__ */ jsx("span", { ref: pctCb, className: "ps-tryon-progress-pct", children: "0%" })
|
|
1086
1105
|
] }),
|
|
1087
|
-
/* @__PURE__ */ jsx("div", { ref:
|
|
1106
|
+
/* @__PURE__ */ jsx("div", { ref: statusCb, className: cx("ps-tryon-processing-text", cn.processingText), children: "Preparing your image..." }),
|
|
1088
1107
|
/* @__PURE__ */ jsx("p", { className: cx("ps-tryon-processing-sub", cn.processingSubText), children: "This usually takes 15-25 seconds" })
|
|
1089
1108
|
] });
|
|
1090
1109
|
}
|