From bd9e632781be4f30b1693be53e5511bac4edb79c Mon Sep 17 00:00:00 2001 From: Max Tarsis <21989873+tarsinzer@users.noreply.github.com> Date: Fri, 14 Jun 2024 06:43:20 +0100 Subject: [PATCH] feat: expose onChange to react wrapper (#110) --- src/ScrollyVideo.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ScrollyVideo.jsx b/src/ScrollyVideo.jsx index 12198fd..2861da0 100644 --- a/src/ScrollyVideo.jsx +++ b/src/ScrollyVideo.jsx @@ -21,6 +21,7 @@ const ScrollyVideoComponent = forwardRef(function ScrollyVideoComponent( videoPercentage, debug, onReady, + onChange, }, ref, ) { @@ -34,6 +35,9 @@ const ScrollyVideoComponent = forwardRef(function ScrollyVideoComponent( const onReadyRef = useRef(onReady); onReadyRef.current = onReady; + const onChangeRef = useRef(onChange); + onChangeRef.current = onChange; + // effect for destroy and recreate on props change (except video percentage) useEffect(() => { if (!containerElement.current) return; @@ -55,8 +59,9 @@ const ScrollyVideoComponent = forwardRef(function ScrollyVideoComponent( lockScroll, useWebCodecs, debug, - videoPercentage: videoPercentageRef.current, onReady: onReadyRef.current, + onChange: onChangeRef.current, + videoPercentage: videoPercentageRef.current, }); setInstance(scrollyVideo);