Skip to content

Commit

Permalink
refactor: prevent invoking setScrollPercent when trackScroll=false
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsisexistence committed Mar 24, 2024
1 parent 4818c3d commit bbebcf1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/ScrollyVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ class ScrollyVideo {
* @param percentage
*/
setScrollPercent(percentage) {
if (!this.trackScroll) {
return;
}

const parent = this.container.parentNode;
const { top, height } = parent.getBoundingClientRect();

Expand Down
3 changes: 1 addition & 2 deletions src/ScrollyVideo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const ScrollyVideoComponent = forwardRef(function ScrollyVideoComponent(
) {
const containerElement = useRef(null);
const scrollyVideoRef = useRef(null);

const [instance, setInstance] = useState(null);

const videoPercentageRef = useRef(videoPercentage);
Expand Down Expand Up @@ -107,7 +106,7 @@ const ScrollyVideoComponent = forwardRef(function ScrollyVideoComponent(
[instance],
);

return <div ref={containerElement} />;
return <div ref={containerElement} data-scrolly-container />;
});

export default ScrollyVideoComponent;

0 comments on commit bbebcf1

Please sign in to comment.