Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript
619 B
Raw Blame
import { useSyncExternalStore } from "react";

// A narrow desktop window still needs the desktop editing workspace.
const COMPACT_EDITOR_QUERY = "(max-width: 1366px) and (hover: none) and (pointer: coarse)";

function subscribe(onChange: () => void): () => void {
  const media = window.matchMedia(COMPACT_EDITOR_QUERY);
  media.addEventListener("change", onChange);
  return () => {
    media.removeEventListener("change", onChange);
  };
}

export function useCompactEditor(): boolean {
  return useSyncExternalStore(
    subscribe,
    () => window.matchMedia(COMPACT_EDITOR_QUERY).matches,
    () => false,
  );
}