Skip to content

Instantly share code, notes, and snippets.

@pigeonfresh
Last active January 21, 2021 01:25
Show Gist options
  • Save pigeonfresh/6d7938ebaf6ad46cfe5b540eeadf6e87 to your computer and use it in GitHub Desktop.
Save pigeonfresh/6d7938ebaf6ad46cfe5b540eeadf6e87 to your computer and use it in GitHub Desktop.
import { gsap, Power3 } from 'gsap';
export const baseTransition = (
elements: HTMLElement | ReadonlyArray<HTMLElement>,
props?: gsap.AnimationVars,
): gsap.core.Animation =>
gsap.from(elements, {
duration: 1.2,
y: 40,
ease: Power3.easeOut,
autoAlpha: 0,
stagger: 0.1,
...props,
});
scrollTransition(this.element, baseTransition(transitionItems));
import { gsap } from 'gsap';
import ScrollTrigger from 'gsap/ScrollTrigger';
gsap.registerPlugin(ScrollTrigger);
export const scrollTransition = (
trigger: HTMLElement,
animation: gsap.core.Animation,
props?: Object,
): gsap.plugins.ScrollTriggerInstance =>
ScrollTrigger.create({
trigger,
animation,
toggleActions: 'play complete none none',
start: 'top 65%',
...props,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment