@ntbjs/react-components 2.0.16-rc.1 → 2.0.16-rc.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewVideoRef.js","sources":["../../src/hooks/usePreviewVideoRef.js"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\n/**\n * Ref for gallery preview videos. Chrome keeps the WebMediaPlayer of a detached\n * <video> alive until GC runs, so scrolling a large gallery exhausts the per-frame\n * player limit and new previews stop loading. Dropping the source the moment React\n * detaches the node releases the player right away. See https://crbug.com/1144736.\n *\n * Returns the ref holding the current node, and the callback ref to put on <video>.\n */\nexport function usePreviewVideoRef() {\n const videoRef = useRef(null);\n\n const setVideoRef = useCallback(node => {\n if (node) {\n videoRef.current = node;\n return;\n }\n\n const video = videoRef.current;\n if (video) {\n video.pause();\n video.removeAttribute('src');\n video.load();\n videoRef.current = null;\n }\n }, []);\n\n return [videoRef, setVideoRef];\n}\n"],"names":["usePreviewVideoRef","videoRef","useRef","setVideoRef","useCallback","node","current","video","pause","removeAttribute","load"],"mappings":";;AAUO,SAASA,kBAAkBA,GAAG;AACnC,EAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAC,IAAI,CAAC,CAAA;AAE7B,EAAA,MAAMC,WAAW,GAAGC,WAAW,CAACC,IAAI,IAAI;AACtC,IAAA,IAAIA,IAAI,EAAE;MACRJ,QAAQ,CAACK,OAAO,GAAGD,IAAI,CAAA;AACvB,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,MAAME,KAAK,GAAGN,QAAQ,CAACK,OAAO,CAAA;AAC9B,IAAA,IAAIC,KAAK,EAAE;MACTA,KAAK,CAACC,KAAK,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"usePreviewVideoRef.js","sources":["../../src/hooks/usePreviewVideoRef.js"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\n/**\n * Ref for gallery preview videos. Chrome keeps the WebMediaPlayer of a detached\n * <video> alive until GC runs, so scrolling a large gallery exhausts the per-frame\n * player limit and new previews stop loading. Dropping the source the moment React\n * detaches the node releases the player right away. See https://crbug.com/1144736.\n *\n * Returns the ref holding the current node, and the callback ref to put on <video>.\n */\nexport function usePreviewVideoRef() {\n const videoRef = useRef(null);\n\n const setVideoRef = useCallback(node => {\n if (node) {\n videoRef.current = node;\n return;\n }\n\n const video = videoRef.current;\n if (video) {\n video.pause();\n // The URL lives on a child <source>, so clearing the video's own src is\n // not enough: load() would re-run resource selection and pick the source\n // again. Remove the children first so selection finds nothing to load.\n video.removeAttribute('src');\n while (video.firstChild) {\n video.removeChild(video.firstChild);\n }\n video.load();\n videoRef.current = null;\n }\n }, []);\n\n return [videoRef, setVideoRef];\n}\n"],"names":["usePreviewVideoRef","videoRef","useRef","setVideoRef","useCallback","node","current","video","pause","removeAttribute","firstChild","removeChild","load"],"mappings":";;AAUO,SAASA,kBAAkBA,GAAG;AACnC,EAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAC,IAAI,CAAC,CAAA;AAE7B,EAAA,MAAMC,WAAW,GAAGC,WAAW,CAACC,IAAI,IAAI;AACtC,IAAA,IAAIA,IAAI,EAAE;MACRJ,QAAQ,CAACK,OAAO,GAAGD,IAAI,CAAA;AACvB,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,MAAME,KAAK,GAAGN,QAAQ,CAACK,OAAO,CAAA;AAC9B,IAAA,IAAIC,KAAK,EAAE;MACTA,KAAK,CAACC,KAAK,EAAE,CAAA;AAIbD,MAAAA,KAAK,CAACE,eAAe,CAAC,KAAK,CAAC,CAAA;MAC5B,OAAOF,KAAK,CAACG,UAAU,EAAE;AACvBH,QAAAA,KAAK,CAACI,WAAW,CAACJ,KAAK,CAACG,UAAU,CAAC,CAAA;AACrC,OAAA;MACAH,KAAK,CAACK,IAAI,EAAE,CAAA;MACZX,QAAQ,CAACK,OAAO,GAAG,IAAI,CAAA;AACzB,KAAA;GACD,EAAE,EAAE,CAAC,CAAA;AAEN,EAAA,OAAO,CAACL,QAAQ,EAAEE,WAAW,CAAC,CAAA;AAChC;;;;"}
|