Skip to content

Instantly share code, notes, and snippets.

@pigeonfresh
Last active November 21, 2020 18:05
Show Gist options
  • Save pigeonfresh/b5f23d622527017553d5fcebbdd0db4a to your computer and use it in GitHub Desktop.
Save pigeonfresh/b5f23d622527017553d5fcebbdd0db4a to your computer and use it in GitHub Desktop.
ScrollTrigger example
export const baseTransition = (transitionItems: ReadonlyArray<HTMLElement>):gsap.core.Animation => gsap.from(transitionItems, {
duration: 1,
y: 40,
autoAlpha: 0,
ease: Expo.easeInOut,
stagger: 0.25,
});
import AbstractBlock from '../AbstractBlock';
import { scrollTransition, baseTransition } from '../../../util/transitions';
export default class CTextBlock extends AbstractBlock {
public static readonly displayName: string = 'c-text-block';
constructor(el: HTMLElement) {
super(el);
const transition = baseTransition(this.getElements('[data-transition-item]'));
scrollTransition(el, transition);
}
public dispose() {
super.dispose();
}
}
import { gsap } from 'gsap';
import ScrollTrigger from 'gsap/ScrollTrigger';
gsap.registerPlugin(ScrollTrigger);
export const scrollTransition = (
trigger: HTMLElement,
animation: gsap.core.Animation,
props?: gsap.plugins.ScrollTriggerInstanceVars,
): gsap.plugins.ScrollTriggerInstance =>
ScrollTrigger.create({
trigger,
animation,
...props,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment