Last active
November 21, 2020 18:05
-
-
Save pigeonfresh/b5f23d622527017553d5fcebbdd0db4a to your computer and use it in GitHub Desktop.
ScrollTrigger example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const baseTransition = (transitionItems: ReadonlyArray<HTMLElement>):gsap.core.Animation => gsap.from(transitionItems, { | |
duration: 1, | |
y: 40, | |
autoAlpha: 0, | |
ease: Expo.easeInOut, | |
stagger: 0.25, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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