@geekapps/silo-elements-nextjs 0.3.2 → 0.3.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.
@@ -183,6 +183,8 @@ function Video({
183
183
  const ageRatingWrapRef = useRef(null);
184
184
  const ageRatingIconRef = useRef(null);
185
185
  const ageRatingTextRef = useRef(null);
186
+ const ageRatingShownRef = useRef(false);
187
+ const ageRatingQueuedRef = useRef(false);
186
188
  const [clickIcon, setClickIcon] = useState(null);
187
189
  const clickIconTimerRef = useRef(null);
188
190
  const clickIconRef = useRef(null);
@@ -257,9 +259,6 @@ function Video({
257
259
  setControlsVisible(false);
258
260
  }, 2400);
259
261
  }
260
- if (video?.paused) {
261
- showAgeRatingRef.current?.();
262
- }
263
262
  }, [autoHideControls]);
264
263
  useEffect(() => {
265
264
  if (!containerRef.current) return;
@@ -430,7 +429,9 @@ function Video({
430
429
  );
431
430
  }
432
431
  tl.to({}, { duration: HOLD });
433
- tl.to(wrap, { opacity: 0, duration: 0.7, ease: "power2.inOut" });
432
+ tl.to(wrap, { opacity: 0, duration: 0.7, ease: "power2.inOut", onComplete: () => {
433
+ ageRatingShownRef.current = true;
434
+ } });
434
435
  ageRatingTlRef.current = tl;
435
436
  };
436
437
  showAgeRatingRef.current = showAgeRating;
@@ -440,10 +441,10 @@ function Video({
440
441
  window.clearTimeout(ageRatingPauseTimerRef.current);
441
442
  ageRatingPauseTimerRef.current = null;
442
443
  }
443
- setHasPlayed((prev) => {
444
- if (!prev) showAgeRating();
445
- return true;
446
- });
444
+ const shouldShow = !ageRatingShownRef.current || ageRatingQueuedRef.current;
445
+ ageRatingQueuedRef.current = false;
446
+ if (shouldShow) showAgeRating();
447
+ setHasPlayed(true);
447
448
  showControlsTemporarily();
448
449
  };
449
450
  const onPause = () => {
@@ -453,7 +454,7 @@ function Video({
453
454
  if (parsed.ageRating?.data) {
454
455
  if (ageRatingPauseTimerRef.current) window.clearTimeout(ageRatingPauseTimerRef.current);
455
456
  ageRatingPauseTimerRef.current = window.setTimeout(() => {
456
- showAgeRating();
457
+ ageRatingQueuedRef.current = true;
457
458
  ageRatingPauseTimerRef.current = null;
458
459
  }, 60 * 1e3);
459
460
  }