Skip to content

Commit

Permalink
add disabled to Root also
Browse files Browse the repository at this point in the history
  • Loading branch information
julianbenegas committed Jul 24, 2023
1 parent 8f60d23 commit ee25209
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scrollytelling/src/primitive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Scrollytelling = ({
scrub,
defaults,
toggleActions,
disabled,
}: {
children?: React.ReactNode;
debug?: boolean;
Expand Down Expand Up @@ -63,6 +64,7 @@ const Scrollytelling = ({
scrub?: boolean | number;
defaults?: gsap.TweenVars | undefined;
toggleActions?: ScrollTrigger.Vars["toggleActions"];
disabled?: boolean;
}) => {
const ref = React.useRef<HTMLDivElement>(null);
const scopedQuerySelector = gsap.utils.selector(ref);
Expand All @@ -73,7 +75,7 @@ const Scrollytelling = ({

// initialize timeline
React.useEffect(() => {
if (!ref.current) return;
if (!ref.current || disabled) return;
gsap.registerPlugin(ScrollTrigger);

const tl = gsap.timeline({
Expand All @@ -95,7 +97,7 @@ const Scrollytelling = ({
return () => {
tl.revert();
};
}, [end, debug, start, callbacks, scrub, defaults, toggleActions]);
}, [end, debug, start, callbacks, scrub, defaults, toggleActions, disabled]);

// rest tween to ensure timeline is always 100 long
const addRestToTimeline = React.useCallback(
Expand Down

1 comment on commit ee25209

@vercel
Copy link

@vercel vercel bot commented on ee25209 Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.