Animations

Triggering animations on scroll in Framer (Animation Lesson 7)

Triggering animations on scroll in Framer (Animation Lesson 7)

Triggering animations on scroll in Framer (Animation Lesson 7)

Joseph

·

14:04

·

30K views

·

About this lesson

The Appear Effect is perfect for adding animations above the fold — since they start automatically when the page loads. But for elements further down the page, we might wanna wait to trigger animations until the visitor scrolls to a certain point. This is exactly where another effect called “Scroll Animations” comes into play.

In this lesson, we’ll look at how to trigger animations in Framer based on scroll position from simple layer reveals to animating entire sections into view.

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=0s Intro

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=44s The three ways to trigger on scroll

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=68s Project overview

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=115s Add a scroll animation to the frame

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=165s Choose the “layer in view” trigger

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=206s Replay behavior: enter vs. exit

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=243s Customize the enter effect (scale in)

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=304s Preview and fine-tune timing

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=471s Switch to the “section in view” trigger

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=508s Set where the section triggers (top/center/bottom)

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=604s Mirror the animation for the right element

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=649s Trigger on scroll for the nav bar

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=754s Tune easing and duration

https://www.youtube.com/watch?v=xpjUbDJYHNA&t=819s Wrap up

Grab the remix link from Framer Academy: https://www.framer.com/academy/lessons/framer-animations-trigger-on-scroll

Sign up: https://framer.link/yt

Follow: https://framer.link/yt-x

Learn: https://framer.link/yt-academy

0:00The appear effect is perfect for adding0:01animations above the fold since they0:04start automatically when the page loads.0:06But for elements further down the page,0:09we might want to wait to trigger0:10animations until the visitor scrolls to0:13a certain point. This is exactly where0:15another effect called scroll animations0:18comes into play. In this lesson, we'll0:20look at how to trigger animations in0:22Framer based on scroll position. From0:24simple layer reveals to animating entire0:27sections into view.0:29[Music]0:32For the lessons in this chapter, we're0:34going to be working with a new project0:35file, and you'll find a link to remix0:37that in the description below. And in0:40this particular lesson, we're talking0:41about triggering animations on scroll,0:44which can be triggered one of three0:46ways, and we're going to go over each0:47one. The first of which is triggering0:50the animation when the animated element0:52itself reaches a certain position. The0:55second is triggering the animation when0:57a section reaches a certain point in the1:00viewport. And the third is triggering1:02the animation just because we're1:04scrolling. Either because we're1:06scrolling down or because we're1:07scrolling up. So, let's take a look at1:09the project that we're working with1:11here. I'm actually going to hop directly1:13into preview mode and just show you that1:15as we scroll down, we have this sort of1:17hero image here that has some animated1:19elements going on inside that. That's1:20actually just a video. And if I continue1:22scrolling, we have this section here1:25which presents with this radial gradient1:27that's spinning. We just basically have1:29a loop effect going on there. And then1:31we have this little graphic element that1:33represents a piece of UI. And we want1:35this and this to animate in. And coming1:38back up here, we want this whole thing1:40to animate in. But we don't want it to1:42animate in when the page loads because1:44those are below the fold, so to speak.1:46We don't see them until the viewer1:48scrolls down a bit. So, we want to1:50trigger those animations once we've1:52reached a certain scroll position. So,1:54what we're going to do first is just1:56select this whole frame. And with this1:58frame selected, I'm going to come down1:59here to effects like we did in the2:01previous chapter. I'm going to click and2:03I'm going to choose to add a scroll2:05animation. Not to be confused with2:07scroll speed or scroll transform, which2:09we're going to talk about in the coming2:10lessons. We're going to start with2:11scroll animation, which again is going2:13to trigger an entire animation on a2:16certain scroll position. So, we're going2:18to reach a scroll position and the2:19animation is just going to play. So,2:21it's kind of like an appear effect, but2:23an appear effect that occurs at a2:25particular scroll position rather than2:27just happening as soon as the page2:28loads. So, here we get a somewhat2:30familiar effect popover. And the first2:33thing we want to choose is the trigger.2:35What is going to trigger this layer to2:37appear? And we have the onappear effect2:40that we discussed in the previous2:42chapter. And then we have on scroll,2:44which we'll talk about in a moment.2:45layer in view, which is what we're going2:47to use here, or section in view. So,2:50we're going to choose layer in view2:51because we want the timing to be2:54relative to the layer itself. So, with2:56layer and view selected, we have the2:58option of timing it so that the layer3:00will appear as soon as the top of it3:02reaches the bottom of the viewport, as3:04soon as the center of it reaches the3:06bottom of the viewport, or as soon as3:08the bottom of it reaches the bottom of3:10the viewport. in which case the whole3:12layer would have to come up into the3:13viewport before the effect even gets3:15triggered. I'm going to go with a happy3:17medium here. I'm going to go with3:18center. So when the center of this frame3:21reaches the bottom of the viewport,3:23that's where the effect is going to get3:25triggered. Then I can choose whether or3:26not I want this effect to replay, which3:29is why we have an enter animation and an3:31exit animation. If we want this to play3:33multiple times as the user scrolls up3:35and down, then we need this to come in3:37and then go away so that it could come3:39back in again, right? In order to3:41replay, we've got to replay sort of the3:43back and forth. So, with the enter3:45animation, we have how this appears. And3:47with the exit animation, we get to3:49decide how it disappears when it crosses3:51over the top of the viewport. But just3:53know that all these preset animations3:55actually come with both an enter and3:58exit animation together. So, I do want4:00this to scale in. I'm going to choose4:01scale in. It applies the scale in enter4:04effect and exit effect. But since I have4:06replay set to no, I actually don't need4:08the exit effect. So, I'm going to get4:10rid of that just to make it more clear4:11that we're only working with one effect4:14here. And when I click on the enter4:15effect, we can actually customize how4:18this is going to come in. So, very much4:19like the appear effect, the enter effect4:21is where we edit what the layer looks4:22like before it animates in. So, it's4:25going to start at 0% opacity. It's going4:27to start at a scale of 0.5 or 50%. I'm4:31actually going to bump that up. I'm4:32going to do a more subtle scale4:34animation where it starts at 70% of its4:37original size instead of starting all4:38the way down at 50%. And then we can4:41have a rotate, skew, offset, etc., just4:43like appear effects. And then down here4:45we have the transition where we4:46determine how the motion actually4:48happens. I'm actually cool with the4:50default spring for this. I'm just going4:52to increase the time. I'm going to make4:54this a little bit slower and more4:55gradual, like 2 seconds. So, I'm going4:58to press command P on my Mac to preview5:00this. Crl + P if you're on a PC. And as5:03I scroll down, we're going to reach that5:05point. There it is. So, as soon as I5:07reach that point where the middle of5:09this frame reached the bottom of the5:10viewport, that's when the animation took5:12place. So, if I scroll up just a little5:14bit and press command R to refresh this5:16so that that animation hasn't taken5:17place yet. I'm going to do it one more5:19time. There it is. As soon as I cross5:20that threshold, we get that animation5:22where we go from a 7 or 70% scale and 0%5:26opacity all the way up to its normal5:29appearance. the way we had it on the5:31canvas. And if I keep scrolling, it5:33doesn't go away because I turned replay5:35off. If I go up and come back down5:37again, it doesn't play again. And that5:39gives us kind of more smooth, reliable5:41performance, and it won't get annoying5:43for the visitor as they're scrolling up5:44and down. They're not going to get hit5:46with that animation over and over again,5:48back and forth. So, let's head back. I'm5:50going to head back to the design canvas,5:53and let's work on the next one because5:55the next one's a little bit different.5:56Down here, we've got this element that I5:59want to slide in from the left, and6:01we've got this element that I want to6:02slide in from the right. But I want both6:04of those to be choreographed so that6:05they happen together at exactly the same6:07time. I don't want one to happen and6:09then the other to happen a little bit6:11later. And as you can see, we've got6:14this element a little bit higher and6:15this element a little bit lower. So, if6:18we have these trigger when the top6:20reaches the bottom of the viewport,6:21well, the tops are in different6:22positions. What about the middle? The6:24middles are in different positions. the6:25bottom the bottoms are in different6:27positions. So every triggering point we6:29have on the layers themselves is in a6:31slightly different position. So the6:32timing is not going to be choreographed6:34together unless we trigger this when a6:38section reaches let's say the top of the6:41viewport. When a section reaches the top6:43of the viewport, we can trigger multiple6:44animations at the same time all based on6:47that one threshold, that one moment in6:50time where that hits the top of the6:52viewport. So that's exactly what we're6:53going to do. And the section we're going6:55to trigger it on is this whole section6:57here, which is this section called all7:00magic. And if I scroll up just a little7:02bit, you can see there is the top of it.7:04So when the top of the frame hits the7:06top of the viewport, that's when I want7:07these things to animate in. But first,7:10before we can tell it that we want this7:12section to be the trigger, we need to7:14make sure that a scroll section is set7:17on the properties panel. So, you can see7:19here I've already set a scroll section,7:21but if there wasn't a scroll section7:22set, I would need to get this frame7:24selected and click to add a scroll7:26section and give it a name. You can name7:28it whatever you want. And you can even7:29add a Y offset if you want to trigger7:31this animation a little bit higher or a7:33little bit lower than the top of the7:35frame, but I'm going to leave that all7:37alone. And I'm going to head back to our7:40gradient container. And that's the first7:42one that I'm going to animate here. So,7:44back down to effects on the properties7:46panel. I'll click to add an effect. I'm7:48going to choose to add a scroll7:49animation again. And here, rather than7:52layer in view, I'm going to switch this7:54to section in view. And then I get to7:57choose which section is going to trigger7:59this. And that one happened to be called8:02section all magic. So that's the one8:04I'll choose. And then here we're going8:06to decide something that looks similar8:07to layer and view, but with section and8:09view, we're actually saying where in the8:12viewport should the top of the section8:14trigger the animation. So, with this set8:17to top, when the top of the section8:19reaches the top of the viewport, trigger8:21it. Here, when the top of the section8:23reaches the center of the viewport,8:25trigger it. And here, when the top of8:27the section reaches the bottom of the8:28viewport, trigger it. I'm going to set8:30this so that the top of the section has8:32to reach the top of the viewport so that8:35the viewer has to scroll a little bit8:37further before this will trigger, at8:39least relative to these other options8:41here. And I don't need this one to8:43replay either. And in this case, instead8:45of fade in, I'm going to have this slide8:48in left, which means slide in from the8:51left. And then because I'm not repeating8:53it, I can get rid of the exit animation8:55and just focus on the enter animation,8:58which is going to start at 0% opacity.9:00And it's not going to scale, it's not9:02going to rotate, it's not going to skew.9:03It's just going to come from a position9:05offset on the xaxis of -50 pixels. And9:09as I move this up and down, you can see9:11that we're really just moving this on9:13the X axis here. But again, I'm happy9:15with negative9:17150. And then we can just focus on the9:20transition, the movement that's going to9:21happen here. Again, I'm cool with the9:23spring, but I am going to make this9:25longer and more dramatic so it's easier9:27for us to see here. I'm going to go all9:28the way to 3 seconds. And then I just9:32want to take pretty much all this and9:33apply it to that little UI element9:36there. So, what I can do here is just9:38right click on the scroll effect that we9:39just created and then choose copy. Then9:43come over here and select this little UI9:45element that I want to animate and then9:47head down here to effects. And instead9:49of just clicking on effects, I'm going9:50to rightclick on effects and choose9:52paste. Now, the problem with this is9:54we've got the one on the left animating9:57from the left. And now we also have the9:58one on the right animating from the10:00left. So, I want the one on the right to10:01animate from the right instead. So, I'm10:03going to go back into the enter effect10:05for this guy, and instead of negative10:08150, I'm going to make that positive10:10150. So, it's coming from 150 pixels to10:13the right. Therefore, it's going to move10:15to the left. And that spring animation10:17is already going to be set because I10:18copied and pasted this whole thing from10:20the other one. And now, we can preview10:22this and see how it's looking. So, we've10:25got our first effect here that happens10:27when the middle of that layer reaches10:29the bottom of the viewport. And then10:30going down a bit further, we want to be10:32watching the top of this section because10:34when the top of this section hits the10:36top of the viewport, there we go. We10:38just triggered this animation and both10:39of these layers came in at exactly the10:41same time because they're both triggered10:43by the same frame. Cool. So, let's head10:46back and I'll show you the one last way10:48that we can trigger an animation on10:50scroll. And for this little header bar10:52or navbar, we're going to make it so10:54that as we scroll down, it moves up and10:56out of the way. And as we scroll up, it10:58comes back. So, with the frame for this11:00whole bar selected, back down to11:02effects. I'm going to click to add an11:03effect. This is again going to be a11:05scroll animation, but here we're going11:07to choose to trigger on scroll, which11:10means trigger on the act of scrolling11:12itself. This isn't about how far we11:14scroll. This is just about whether11:16scrolling is taking place. Is scrolling11:19down happening? Is scrolling up11:22happening? And for this one, we're going11:23to trigger the effect of the bar moving11:25up and out of the way when scrolling11:27down. and then it'll return to its11:29normal position when scrolling up11:31instead. And for this one, we do want to11:33leave replay turned on. So that way as11:35you scroll down, it'll get out of the11:36way. As you scroll up, it'll come back11:38and vice versa no matter how many times11:40you scroll up and down. And the closest11:43preset that I could start with is11:45probably slide out top because slide out11:48top is going to have an effect that11:50moves it up in this case 150 pixels,11:53which is actually excessive because our11:55navbar is only 64 pixels tall. So, we11:58could set this to exactly 64 or we could12:00round up to 70. So, that way the12:03transition is taking place over an12:04appropriate distance because if we tell12:06this to move an unnecessary amount, it's12:08going to have to move faster in order to12:11get to that point in the same amount of12:13time. So, if we want our duration to12:16correlate more accurately to the actual12:18transition that's visible, we only want12:20it to move as far as what we can see. So12:24in the case of a navbar, we want it to12:26move up by pretty much its own height.12:29So in this case, transition is set to12:3104, which is a little on the quick side.12:34I'll, you know, let's just do 0.5. And12:36one little problem we're going to have12:38with spring is that it's going to12:39overshoot by just a little bit. And we12:42don't want the navbar to come down too12:43far. So I'm actually going to switch12:44this from spring to ease. And we'll12:47leave it on ease in and out. So that way12:49we can see it ease in on its way up and12:52ease out on its way down. And again,12:54time set to 0.5. That's looking good.12:57And let's preview this and see what12:58we've got. And there we go. As I scroll13:01down, it gets out of the way. As I13:03scroll up, it comes right back. And you13:05can see here that in the effect, it is13:07fading in. And we don't necessarily need13:09it to fade in since it's coming in from13:12off the screen. So I'm going to revisit13:14the effect itself. And I'm gonna say,13:16you know what? Let's start at 100%13:19opacity since we can't see it anyways.13:21And then we'll have it move in without13:22the fade. And we'll preview that again.13:25And that is looking good. Now we don't13:27have that unnecessary fade. We've just13:30got the movement in. And as we scroll13:32down, boom, we've got that animation.13:34And again, everything is working13:36together here in perfect harmony. And13:38there you have it. Scroll animations can13:40trigger effects with the rhythm and13:42pacing set by the visitor as they scroll13:45down the page, guiding them naturally13:46through your content, one reveal at a13:49time. That's it for this one. I'll see13:51you in the next one.

Watch on YouTube ↗

More in this topic

Framer Update: Logo Shaders2:05
Framer Update: Logo Shaders
Framer Update12K views · 1 month ago
Framer Update: Holo Shader1:46
Framer Update: Holo Shader
Framer Update6K views · 2 months ago
Shader: Chromatic Aberration1:56
Shader: Chromatic Aberration
Framer Update7K views · 2 months ago
Framer Shaders2:28
Framer Shaders
Announcement23K views · 2 months ago
Framer Update: Flow Effect in Layout Templates2:12
Framer Update: Flow Effect in Layout Templates
Framer Update10K views · 3 months ago
Building an Expanding Article Stack in Framer13:14
Building an Expanding Article Stack in Framer
Animations4K views · 4 months ago
Scaling a clipped image on hover in Framer5:41
Scaling a clipped image on hover in Framer
Animations7K views · 5 months ago
Making elements revolve in Framer3:38
Making elements revolve in Framer
Animations5K views · 5 months ago

Create a free website with Framer, the website builder loved by startups, designers and agencies.