Skip to content

Commit

Permalink
feat: expose onChange to react wrapper (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsisexistence committed Jun 14, 2024
1 parent d65cd75 commit bd9e632
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ScrollyVideo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ScrollyVideoComponent = forwardRef(function ScrollyVideoComponent(
videoPercentage,
debug,
onReady,
onChange,
},
ref,
) {
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit bd9e632

Please sign in to comment.