canvu-react 0.4.75 → 0.4.77

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.
@@ -449,7 +449,7 @@ function requestRuntimeAnimationFrame(callback) {
449
449
  }
450
450
  function cancelRuntimeAnimationFrame(handle) {
451
451
  const runtime = globalThis;
452
- if (typeof runtime.cancelAnimationFrame === "function") {
452
+ if (typeof runtime.cancelAnimationFrame === "function" && typeof handle === "number") {
453
453
  runtime.cancelAnimationFrame(handle);
454
454
  return;
455
455
  }
@@ -524,7 +524,7 @@ function useRealtimePeerFollow(options) {
524
524
  const [, setViewportSizeVersion] = useState(0);
525
525
  useEffect(() => {
526
526
  if (!followedPeerId) return;
527
- let animationFrameId = 0;
527
+ let animationFrameId = null;
528
528
  let lastViewportSizeKey = getViewportSizeKey(viewportRef.current ?? null);
529
529
  const checkViewportSize = () => {
530
530
  const nextViewportSizeKey = getViewportSizeKey(viewportRef.current ?? null);
@@ -536,7 +536,9 @@ function useRealtimePeerFollow(options) {
536
536
  };
537
537
  animationFrameId = requestRuntimeAnimationFrame(checkViewportSize);
538
538
  return () => {
539
- cancelRuntimeAnimationFrame(animationFrameId);
539
+ if (animationFrameId !== null) {
540
+ cancelRuntimeAnimationFrame(animationFrameId);
541
+ }
540
542
  };
541
543
  }, [followedPeerId, viewportRef]);
542
544
  useEffect(() => {