GSAP & ScrollTrigger Crash Course for Webflow

Timothy Ricks
6 Dec 202316:08

Summary

TLDRThis tutorial demonstrates how to use Gap and Scroll Trigger to create advanced web animations in Webflow. It covers adding the necessary libraries, using Code Sandbox for coding, and animating elements like thumbnails, titles, and hero images with various properties and durations. The lesson also explores creating staggered animations, timelines for sequenced animations, and looping animations. Additionally, it teaches how to control animations with scroll triggers and handle multiple instances of the same element on a page.

Takeaways

  • πŸ˜€ The Gap and Scroll Trigger are powerful tools for creating advanced interactions in Webflow.
  • πŸ“š To get started, you need to add the Gap and Scroll Trigger libraries to your Webflow project through the site settings or before the closing body tag.
  • πŸ”— Visit gap.com to install the libraries and get the CDN links for Scroll Trigger.
  • πŸ’» Use a tool like Code Sandbox to write and update your code without needing to republish your site.
  • πŸ–ŒοΈ Gap allows you to animate elements by passing in properties such as scale, opacity, and transform within the brackets.
  • πŸ”„ The 'from' animation in Gap animates elements from a specified state back to their original Webflow state.
  • πŸ•’ Gap has a default duration of 0.5 seconds for animations, but this can be customized to any desired length.
  • πŸ“ The 'gap.set' function instantly sets an element's style without animation, useful for setting initial states.
  • πŸ”„ Ease types in Gap define the speed curve of the animation, and you can customize these for different effects.
  • 🎨 Gap enables easy creation of stagger animations, which can be controlled by the 'stagger' parameter.
  • πŸ“Š The 'amount' parameter in stagger animations helps manage the start times distribution for a dynamic number of items.
  • πŸ“ˆ Gap timelines allow for sequencing of animations and can be controlled with various methods such as pause, play, and reverse.
  • πŸ”„ The 'yo-yo' property in Gap timelines makes an animation play forwards and then backwards, useful for infinite loops.
  • πŸ” Scroll Trigger settings let you define when an animation should start and end based on the scroll position of specific elements on the page.
  • πŸ”„ The 'toggle actions' in Scroll Trigger provide granular control over what happens when a section enters and leaves the viewport.
  • πŸ”„ For multiple instances of a section on a single page, use a jQuery each loop to ensure each section triggers its own animations.

Q & A

  • What are the two main tools discussed in the script for creating advanced interactions in Webflow?

    -The two main tools discussed are Gap and Scroll Trigger.

  • How can one add the Gap and Scroll Trigger libraries to a Webflow project?

    -You can add the Gap and Scroll Trigger libraries by going to page or site settings and adding the CDN links provided by visiting gap.com and checking the Scroll Trigger option.

  • What is Code Sandbox and how is it used in the context of this script?

    -Code Sandbox is a tool for writing and updating code without needing to republish the site. It is used to create a new file, script.js, where the animation code is written and then linked to the Webflow project.

  • How do you animate thumbnail images using Gap in the script?

    -To animate thumbnail images, you type 'gap.2' inside the parentheses, add the class name, and then pass in properties like 'scale: 0' to animate the images to a scale of zero from their original scale in Webflow.

  • What is the default duration for animations in Gap if not specified?

    -The default duration for animations in Gap is 0.5 seconds.

  • How can you change the animation type to a 'from' animation in Gap?

    -To change the animation type to a 'from' animation, you specify the type as 'from' and set the initial state of the animation, such as animating from a scale of zero back to the original scale in Webflow.

  • What does the 'gap.set' function do in the script?

    -The 'gap.set' function instantly sets the style of an element without needing to use a duration, effectively applying the style immediately on page load.

  • How can you create a stagger animation with Gap?

    -To create a stagger animation, you add 'stagger' inside squiggly brackets with a specified duration, such as 'each 0.5s', to stagger the start times of the animations.

  • What is a Gap timeline and how is it used to sequence animations?

    -A Gap timeline is a sequence of animations that are executed in a specific order. It is created using 'gap.timeline' and steps are added to the timeline to control the order of animations.

  • How can you control a Gap timeline using the console in the browser?

    -You can control a Gap timeline using methods like '.pause()', '.play()', '.reverse()', and '.timeScale()' by accessing the console in the browser and applying these methods to the timeline.

  • What is the purpose of the 'scroll trigger' in the script?

    -The 'scroll trigger' is used to initiate animations only after certain sections of the page are scrolled into view, providing control over when and how animations are triggered.

  • How can you ensure that each section of a page triggers its own animations?

    -You can use a jQuery each loop to iterate through all instances of a section on the page, setting each section as its own trigger for its child elements.

Outlines

00:00

🌐 Introduction to Gap and Scroll Trigger in Webflow

This paragraph introduces the powerful tools Gap and Scroll Trigger for creating advanced interactions in Webflow. The speaker explains how to add these libraries to a Webflow project by installing them from gap.com and copying the CDN links to the project's before closing body tag. The use of Code Sandbox is highlighted as a tool for writing and updating code without republishing the site. The first task is to animate thumbnail images using Gap, demonstrating how to apply animations with different properties, durations, and easing types. The paragraph also covers the creation of stagger animations and the use of Gap.set for instant style changes.

05:01

🎬 Advanced Animation Techniques with Gap

The speaker delves deeper into advanced animation techniques using Gap, focusing on animating other elements like title wraps and hero images. The paragraph explains how to create sequences in animations using Gap.timeline, which allows for the control of animation order and timing. Techniques such as using position parameters to offset animations and creating looping animations with Gap.timeline are discussed. The paragraph also covers the use of callbacks and methods like pause, play, and reverse to control timelines, providing examples of how these can be implemented in Webflow projects.

10:02

πŸ“š Scroll Trigger Setup and Animation Control

This paragraph discusses the setup and control of animations using Scroll Trigger. The speaker explains how to create timelines that animate elements based on scroll position, using the trigger element and start/end points to define when animations should begin and end. The use of percentage-based points and the scrub parameter for smooth animation synchronization with scrolling is highlighted. The paragraph also covers the use of toggle actions to play, pause, resume, reset, restart, or reverse animations based on the section's visibility. Techniques for handling multiple sections on a single page and ensuring each section triggers its own animations are also discussed.

15:02

πŸ”„ Individual Section Triggers with jQuery Each Loop

The final paragraph addresses the issue of multiple sections on a single page triggering animations simultaneously. The speaker introduces a solution using a jQuery each loop to ensure that each section triggers its own images independently. The paragraph explains how to loop through all about sections on the site and create a timeline for each section, animating only the child images within the current section. This approach ensures that animations are controlled at an individual section level, providing a more refined user experience and precise control over animations in Webflow projects.

Mindmap

Keywords

πŸ’‘Gap

Gap is a powerful animation library used in web development, specifically within Webflow. It allows developers to create advanced interactions and animations for web elements. In the video, Gap is used to animate thumbnail images, titles, and other elements by applying properties like scale, opacity, and transform. It is integral to the theme of creating dynamic and responsive web animations.

πŸ’‘Scroll Trigger

Scroll Trigger is a feature that enables animations to be triggered based on the user's scroll position. It is used in conjunction with Gap to create interactive and engaging user experiences. The script mentions adding Scroll Trigger settings to timelines, which control when animations start based on the visibility of certain sections of the webpage.

πŸ’‘Code Sandbox

Code Sandbox is an online code editor that allows developers to write and test code without needing to republish their site. In the context of the video, Code Sandbox is used to write JavaScript code for animations, which is then linked to the Webflow project. This tool facilitates the development process by providing a live preview of changes.

πŸ’‘Thumbnail Images

Thumbnail images are smaller, clickable versions of larger images used on websites. In the video, the script demonstrates how to animate these images using Gap, changing their scale and opacity to create a visually appealing effect. This is an example of how Gap can be used to enhance the user interface.

πŸ’‘Animation Properties

Animation properties refer to the specific attributes that can be animated, such as scale, opacity, and transform. The video script discusses how to use Gap to animate these properties, providing examples of how they can be manipulated to create different effects, such as scaling images up or down or changing their opacity.

πŸ’‘Easing

Easing in animation refers to the rate of change of a parameter over time. It defines how an animation starts and ends, making it appear more natural. The script mentions 'power one out' as an example of an easing type, which can be adjusted to create smoother transitions in animations.

πŸ’‘Stagger Animations

Stagger animations are a technique where multiple elements are animated sequentially, creating a sense of depth and order. In the video, Gap is used to stagger the start times of image animations, which helps in managing the visual flow and preventing elements from appearing simultaneously, thus enhancing the overall aesthetic.

πŸ’‘Timeline

A timeline in animation is a sequence of events or steps that define the order and duration of animations. The video script discusses creating timelines using Gap, which allows for the orchestration of multiple animations in a specific sequence. This is crucial for creating complex animations that require synchronization.

πŸ’‘Looping

Looping in animation refers to the repetition of an animation sequence. The video demonstrates how to set up a looping timeline using Gap, which can repeat an animation multiple times or indefinitely. This is useful for creating continuous effects, such as a background element that continuously moves.

πŸ’‘jQuery

jQuery is a fast, small, and feature-rich JavaScript library. It simplifies HTML document traversing, event handling, and animation. In the video, jQuery is mentioned as a tool to loop through multiple sections on a page, allowing each section to trigger its own animations independently, which is essential for handling dynamic content.

πŸ’‘Callbacks

Callbacks in programming are functions that are to be executed after certain events occur. In the context of the video, callbacks like 'onComplete' are used with Gap timelines to trigger actions when an animation step is completed. This provides a way to control the flow of animations and add interactivity.

Highlights

Introduction to Gap and Scroll Trigger as powerful tools for creating advanced interactions in Webflow.

Instructions on adding Gap and Scroll Trigger libraries to a Webflow project via page or site settings.

Explanation of how to install and use the CDN for Gap and Scroll Trigger.

Use of Code Sandbox for writing and updating code without republishing the site.

Demonstration of animating thumbnail images using Gap with a 'from' animation type.

Adjusting animation duration and type to create different visual effects.

Utilizing 'gap.set' to instantly style elements without animation duration.

Animating multiple properties and handling properties with special naming conventions in Gap.

Creating fade and border radius animations with a custom duration.

Customizing ease types for animations in Gap and adding them to projects.

Creating stagger animations to delay the start of each animated element.

Using 'amount' to distribute start times for a dynamic number of animating items.

Animating other elements like title wraps and hero images with Gap from animations.

Introducing Gap timelines for sequencing animations and controlling their order.

Using position parameters to adjust the start time of animations within a timeline.

Creating looping animations with Gap timelines and controlling them with various methods.

Controlling timelines through console methods like pause, play, and reverse.

Setting up Scroll Trigger to animate elements based on scroll position.

Configuring Scroll Trigger settings like trigger element, start and end points, and markers.

Using percentage-based points and toggle actions for fine-tuned Scroll Trigger control.

Implementing granular control over animations at the entry and exit of scroll view.

Addressing the issue of multiple section triggers on a single page with jQuery each loop.

Final setup recommendations for Scroll Trigger to ensure smooth and controlled animations.

Invitation to learn more about advanced Gap libraries through the provided Patreon link.

Transcripts

play00:00

Gap and scroll trigger are by far the

play00:02

most powerful tools we have for creating

play00:04

Advanced interactions in webflow in this

play00:07

lesson we'll recreate these interactions

play00:08

and cover everything you need to know

play00:10

starting with the absolute Basics first

play00:13

let's add the Gap and scroll trigger

play00:15

libraries to our web flow project this

play00:17

can go in page or site settings in the

play00:20

before closing body tag let's go to

play00:23

gap.com install here we'll click on the

play00:26

CDN Tab and check scroll trigger this

play00:29

gives us the GSA and scroll trigger

play00:30

links that we can copy and add to

play00:33

webflow we'll be using a tool called

play00:35

code sandbox to write our code so we can

play00:37

update it without having to republish

play00:39

our site let's copy the first line add

play00:42

it below the others and we'll replace

play00:44

this URL with a link to our code sandbox

play00:46

file create a free account on codes

play00:49

sandbox. click create a Sandbox HTML CSS

play00:54

and create sandbox from here we'll

play00:57

create a new file using this icon and

play00:59

we'll call this

play01:01

script.js let's copy the link to our

play01:03

code sandbox and in webflow we'll paste

play01:06

it in and Target our script.js file

play01:09

let's save and publish our site the

play01:12

first thing we'll animate are these

play01:13

thumbnail images let's copy their class

play01:16

and head to code sandbox we'll close

play01:18

this preview window and close the side

play01:21

panel to animate with gap let's type

play01:23

gap. 2 inside the parentheses We'll add

play01:26

quotes period and paste our class Name

play01:29

by behind the quotes we'll add a comma

play01:31

and squiggly brackets inside these

play01:33

brackets we can pass in any properties

play01:35

we want to animate I'll pass in scale

play01:38

colon Z here we're animating all our

play01:40

thumbnail images to a scale of Zero from

play01:44

whatever the scale was in web flow so if

play01:47

we save that notice how all our images

play01:49

animate to scale zero if we don't pass

play01:52

in a duration the default duration in

play01:54

gap is 0.5 seconds let's change that to

play01:57

2 seconds we can also change change our

play02:00

type of Animation to a from animation

play02:02

here our images will animate from a

play02:04

scale of zero back to whatever the scale

play02:07

was in webflow so if we refresh notice

play02:09

our images animate up from a scale of

play02:12

zero we can also do a from to animation

play02:15

and this allows us to set the initial

play02:17

State We'll add squiggly brackets and a

play02:19

comma and here we won't pass a duration

play02:22

just the property so we'll animate from

play02:24

a scale of two to a scale of zero over a

play02:28

duration of 2 seconds and if we save

play02:30

this notice our images start really

play02:32

large and scale down to zero and the

play02:35

last thing we can use is a gap. set this

play02:38

instantly sets the image to a certain

play02:41

style without needing to use a duration

play02:43

so they'll instantly be a scale of zero

play02:46

on page load using a gap. set we can

play02:49

also add multiple properties in

play02:51

whichever order we'd like let's animate

play02:54

with a gap. from from an opacity of zero

play02:58

and from a border radius of three rim

play03:00

for any property that uses two words

play03:03

we'll delete the dash and capitalize the

play03:05

second word if we use a number this

play03:07

would be three pixels but for a certain

play03:10

unit we'll wrap it in quotes and we can

play03:12

add three Rim I'll have this happen over

play03:14

a duration of 1 second and if we save

play03:17

with command s refresh our site these

play03:19

Fade up and the Border radius opens all

play03:22

animations in gap have a default ease of

play03:25

power one out I'll leave a link to this

play03:27

ease visualizer in the description below

play03:29

each number is getting progressively

play03:31

stronger and we can change the EAS type

play03:34

here and copy it into our project we can

play03:36

add it anywhere inside the squiggly

play03:38

brackets like so to apply a different

play03:41

ease one of the coolest Parts about Gap

play03:43

is its ability to easily create stagger

play03:46

animations let's animate all our images

play03:48

from a scale of zero and we'll stagger

play03:50

their start times We'll add stagger open

play03:53

en Clos squiggly brackets and add a

play03:55

comma inside the brackets we can pass in

play03:58

each 0.5 5 this will put 0.5 seconds in

play04:02

between the start time of each image so

play04:04

our total duration is going to be 2.5

play04:07

seconds and the more images we add the

play04:10

longer our animation will become instead

play04:13

of each we can also use amount this will

play04:16

distribute the start times of the images

play04:18

across 0.5 seconds so no matter how many

play04:21

images we add our total duration will

play04:23

never be longer than 1.5 seconds amount

play04:27

is great when we have a dynamic number

play04:29

of items we're animating if we save this

play04:32

and refresh our site we should notice

play04:34

they all kind of scale up and they're

play04:36

staggering from the first one in the

play04:37

list all the way to the end we can also

play04:40

customize where they stagger from though

play04:43

right after amount we'll add comma from

play04:45

and in quotes we'll pass in from the end

play04:47

of the list so if we save that and

play04:50

refresh it'll start at the end and

play04:52

stagger back to the beginning we can

play04:54

also do sensor so it'll stagger from the

play04:56

middle item or random so every time we

play04:58

refresh the page it'll stagger in a

play05:01

random order next let's grab a couple

play05:03

other elements to animate like this

play05:05

title wrap we can copy its class and

play05:08

create a new line in our code we'll do a

play05:10

gap. from on our title wrap from an

play05:13

opacity of zero and from a y transform

play05:16

of six Rim so it's pushed down and it'll

play05:19

slide up this can happen over a duration

play05:21

of 1 second let's also grab this large

play05:24

image here our hero image we'll copy

play05:27

that class and do a gap got from on the

play05:30

hero image animate it from an opacity of

play05:33

zero and from a scale of 0.8 this can

play05:37

happen over a duration of 2 seconds so

play05:40

if we save that we should notice now our

play05:42

title sliding up and this image scaling

play05:45

up but these are all happening at the

play05:47

same time we might want to create some

play05:49

kind of a sequence to our animation so

play05:52

let's come back here and we'll create a

play05:54

gap timeline so we'll say let to create

play05:57

our timeline and we can name it whatever

play05:58

we'd like I'll call this load TL for

play06:01

load timeline we'll set it equal to gap.

play06:04

timeline and then to add these steps to

play06:07

our timeline all we need to do is

play06:08

replace Gap with the name of our

play06:10

timeline this will happen in the order

play06:12

we laid out here so the Second Step will

play06:15

only start animating after the first

play06:17

step is completely finished if we save

play06:20

that and refresh the title comes in then

play06:23

the images than this large image but we

play06:26

might want them to slightly overlap each

play06:28

other so to do that we can use a

play06:30

position parameter let's add a comma

play06:32

after the squiggly bracket and we can

play06:34

pass in a number I'll say5 seconds so

play06:37

this step will happen now 05 seconds

play06:39

from the start of the entire timeline

play06:41

this acts kind of like position absolute

play06:44

we're just absolu it to the beginning of

play06:45

the whole timeline and offsetting it by

play06:48

0.5 seconds but we can use a relative

play06:51

position parameter by wrapping this in

play06:52

quotes using a less than sign and here

play06:55

we're saying let this step start at the

play06:57

beginning of the previous step but we

play07:00

might want to offset that a little so

play07:01

we'll say at the beginning of the

play07:03

previous step plus5 seconds we can also

play07:06

use a greater than sign to say let this

play07:09

step start at the end of the previous

play07:11

step which is what it would normally do

play07:13

but then we can say minus5 seconds so it

play07:16

cuts half a second into the previous

play07:18

step for now we'll just have it start at

play07:20

the beginning plus5 and if we save that

play07:23

and we come back here now we should

play07:24

notice while these are still animating

play07:27

this image starts to come in next let's

play07:29

create a new timeline we'll call this

play07:31

Loop TL and set it equal to gap.

play07:34

timeline we'll say Loop TL do2 on our

play07:37

hero image let's animate this image to a

play07:40

y of -1 rim and over a duration of 1

play07:45

second and with an ease of power one in

play07:48

out so we're easing the start and end

play07:50

now in our timeline we can add squiggly

play07:52

brackets to open the settings let's pass

play07:54

in repeat four so our timeline repeats

play07:57

four times if we save and refresh we

play08:00

should notice this image sliding up and

play08:02

then it just keeps restarting until the

play08:04

four times is over to make this feel

play08:06

more smooth though we might need to

play08:08

slide our image back down to zero before

play08:11

repeating or another way we could handle

play08:13

this is in our timeline settings we can

play08:16

pass in yo-yo true which means it will

play08:18

play forwards and then backwards and we

play08:21

can change repeat to negative 1 so it

play08:23

repeats infinite number of times if we

play08:26

save and refresh our image should start

play08:28

sliding up and down smoothly and that

play08:30

should just keep repeating let's right

play08:32

click on our page and click inspect and

play08:35

click on console for any timeline

play08:37

there's different methods we can use to

play08:39

control it let's grab our Loop TL and

play08:41

do. pause hit enter and it pauses the

play08:44

timeline I'll hit my up Arrow key change

play08:47

this to playay and it resumes the

play08:49

timeline we can also do reverse this

play08:51

means on click or hover of a link we

play08:53

could play pause or reverse our timeline

play08:56

giving us a lot of control this is one

play08:58

of the greatest things things about

play08:59

timeline and we can also do time scale

play09:03

and one would be its default speed three

play09:05

would be three times the original speed

play09:07

so we can speed it up while it's playing

play09:09

there's all different methods we can use

play09:11

on a timeline but here we might want our

play09:14

timeline to only start after the image

play09:16

is fully scaled up to do that we can

play09:19

pass in pause to true so the timeline is

play09:22

paused on page load and then for this

play09:25

step here we can pass in a call back

play09:27

I'll do on complete that means when this

play09:30

step is completed we can do Loop TL

play09:33

doplay so we'll play our timeline only

play09:36

after this step is completed there's all

play09:38

different callbacks we can use like on

play09:40

start on reverse reverse complete so

play09:44

definitely look into those callbacks

play09:46

here but the great thing about this is

play09:48

this looping timeline will only start

play09:50

after the image is fully scaled this is

play09:52

great for things like page loaders or

play09:54

different things where we may only want

play09:56

the hero to animate after this preloader

play09:58

is finished next let's animate this

play10:00

final section here we have a bunch of

play10:02

images stacked on top each other let's

play10:04

copy their class and head to our code

play10:07

we'll create a new timeline called

play10:08

scroll TL set to gap. timeline and we'll

play10:12

add a step to this timeline scroll TL

play10:15

from on our about images we animate them

play10:18

from opacity 0 from a scale of 0.8 over

play10:23

a duration of

play10:24

0.15 and we'll add a stagger to offset

play10:27

the starts of each of them by

play10:29

0.4 so once we save that if we refresh

play10:32

here we should notice these images start

play10:34

to come in but they started before we

play10:36

were scrolled into view so we need to

play10:38

make sure these only animate after we're

play10:41

scrolled into view of this about section

play10:44

so to do that let's open our timeline

play10:46

settings and I'll hit enter and pass in

play10:48

scroll trigger scroll trigger accepts

play10:51

its own settings the first being the

play10:53

trigger element in our case it's the

play10:55

about section and the start Point it'll

play10:58

be when the top of that section reaches

play11:00

Center of screen for us the end point

play11:02

will be whenever the bottom of section

play11:04

reaches bottom of screen and we can also

play11:06

pass in markers true just so we get a

play11:09

visual preview of these two points while

play11:10

we're building I'll also add scrub true

play11:13

so while we're scrolling past these

play11:15

we'll be scrubbing the timeline with our

play11:17

scroll bar so if we save that and

play11:19

refresh notice we have these nice

play11:21

markers now and whenever the top of this

play11:24

section reaches Center of screen we're

play11:26

starting to scrub our timeline and

play11:28

whenever the bottom of that section

play11:30

reaches bottom of screen our timeline is

play11:32

over now we can also pass in percentage

play11:35

based points instead of keywords like

play11:37

top Center bottom we could say when 10%

play11:40

from the top of the section reaches 40%

play11:43

from the top of the screen and if we

play11:45

save and refresh now we'll notice that

play11:48

this start point is 40% from top of

play11:50

screen and this start point is 10% from

play11:53

the top of the section let's change our

play11:55

trigger points to start when top of

play11:57

section reaches 40% from Top top of

play11:59

screen and ends when bottom of section

play12:01

reaches 50% from top of screen instead

play12:04

of scrub true we could also add a number

play12:06

here that means if we abruptly stop

play12:09

scrolling it'll take about 2 seconds for

play12:11

the animation to catch up to our scroll

play12:13

bar the higher the number the more

play12:15

smooth this can feel instead of scrub we

play12:17

could also add toggle actions this means

play12:20

when we scroll into view of our section

play12:22

our animation will play at this duration

play12:25

instead of scrubbing it for toggle

play12:27

actions there's four points we can

play12:29

consider the keywords we can use for

play12:31

those are play pause resume reset

play12:34

restart complete reverse and none so if

play12:37

we were to check out those four points

play12:40

the first is when the top of section

play12:42

enters View and the second point is when

play12:45

the bottom of section leaves view the

play12:47

third point is when the bottom of

play12:49

section re-enters View and then the

play12:51

fourth point is when the top of section

play12:54

exits out so if we were to take that

play12:57

into consideration let's say when the

play12:59

section enters view will play when it

play13:01

leaves from the bottom we will pause

play13:04

when it re-enters through the end we

play13:06

will resume and when it exits out past

play13:09

the top we will reverse so if we were to

play13:12

save that and refresh we should notice

play13:15

now whenever we enter it plays exit past

play13:18

the bottom it would pause re-enter it

play13:21

resumes and then exit past the top it

play13:24

reverses so we get really granular

play13:27

control of what we want to happen at

play13:29

these four points the setup I usually

play13:31

like to use is start whenever the top of

play13:34

section reaches bottom of screen so it's

play13:36

just peeking in at the bottom and ends

play13:39

whenever the top of section reaches

play13:41

whatever percent offset I want from top

play13:43

of screen maybe like 70% from top of

play13:46

screen and we'll just take a look at

play13:48

what those four points will look like so

play13:50

if we were to save this and refresh here

play13:53

we'll notice our start point is when top

play13:56

of section reaches bottom of screen and

play13:58

for that we'll do nothing our endpoint

play14:01

is when the top of section exits past

play14:03

that 70% from top of screen and for that

play14:05

we'll play our animation the next point

play14:08

is when the top of section re-enters

play14:10

here and for that we do nothing and the

play14:12

last point is when the top of section

play14:14

goes out and it's completely out of view

play14:16

and for that I'd usually reset the

play14:18

animation so it's ready to play again

play14:20

when we come back in So to see that in

play14:22

action when it enters out the bottom do

play14:25

nothing when it crosses that thres hole

play14:27

70% from top we'll play when it

play14:30

re-enters past that 70% do nothing and

play14:33

then when it goes out past the bottom of

play14:35

screen we will reset the animation

play14:37

completely so if we save that and

play14:40

refresh now we'll see that it's

play14:42

completely hidden until we reach that

play14:45

70% Mark when we cross back past the 70%

play14:48

Mark we're not seeing it reverse yet

play14:50

it's just waiting and it doesn't clear

play14:52

out till the sections completely out of

play14:54

view and then it's ready to be played

play14:55

again the last thing to consider is what

play14:58

happen happens if we have multiple

play14:59

copies of this about section on a single

play15:02

page whenever that happens the first

play15:04

section acts as a trigger triggering all

play15:07

of the images instead we want each

play15:09

section to trigger its own images to do

play15:12

that I like to use a jQuery each Loop

play15:15

I'll Loop through all of the about

play15:16

sections on the site and we can do do

play15:20

each and I'll open up parentheses create

play15:23

a function open this squiggly brackets

play15:26

and I'll move all this timeline code

play15:28

inside my each Loop so now for my

play15:31

trigger element I can replace this with

play15:33

the keyword this which just refers back

play15:36

to the section I'm looping through and

play15:38

instead of animating all about images I

play15:41

can grab this section and find only the

play15:44

child about images inside of the current

play15:46

section I'm looping through when I save

play15:49

that and I refresh it treats each

play15:51

section as its own trigger so when this

play15:54

section comes into view the images

play15:56

inside it play and when the second

play15:58

section comes to view the images inside

play16:00

that play if you'd like to learn more

play16:02

about scroll trigger and other Advanced

play16:04

Gap libraries check out my Patron in the

play16:07

description below

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
WebflowGapScroll TriggerAnimationsCode SandboxCSSJavaScriptStagger EffectsTimeline ControlDynamic Content