canvu-react 0.4.74 → 0.4.76

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.
@@ -471,7 +471,7 @@ function requestRuntimeAnimationFrame(callback) {
471
471
  }
472
472
  function cancelRuntimeAnimationFrame(handle) {
473
473
  const runtime = globalThis;
474
- if (typeof runtime.cancelAnimationFrame === "function") {
474
+ if (typeof runtime.cancelAnimationFrame === "function" && typeof handle === "number") {
475
475
  runtime.cancelAnimationFrame(handle);
476
476
  return;
477
477
  }
@@ -546,7 +546,7 @@ function useRealtimePeerFollow(options) {
546
546
  const [, setViewportSizeVersion] = react.useState(0);
547
547
  react.useEffect(() => {
548
548
  if (!followedPeerId) return;
549
- let animationFrameId = 0;
549
+ let animationFrameId = null;
550
550
  let lastViewportSizeKey = getViewportSizeKey(viewportRef.current ?? null);
551
551
  const checkViewportSize = () => {
552
552
  const nextViewportSizeKey = getViewportSizeKey(viewportRef.current ?? null);
@@ -558,7 +558,9 @@ function useRealtimePeerFollow(options) {
558
558
  };
559
559
  animationFrameId = requestRuntimeAnimationFrame(checkViewportSize);
560
560
  return () => {
561
- cancelRuntimeAnimationFrame(animationFrameId);
561
+ if (animationFrameId !== null) {
562
+ cancelRuntimeAnimationFrame(animationFrameId);
563
+ }
562
564
  };
563
565
  }, [followedPeerId, viewportRef]);
564
566
  react.useEffect(() => {