Animations

Creating persistent animations between pages in Framer (Animation Lesson 15)

Creating persistent animations between pages in Framer (Animation Lesson 15)

Creating persistent animations between pages in Framer (Animation Lesson 15)

Joseph

·

7:42

·

10K views

·

About this lesson

When elements are shared between pages, it can still feel a bit jarring... or at least unnecessary for those elements to transition away only to come right back a moment later.

Fortunately, Layout Templates in Framer have a trick up their sleeve. In this lesson, I’ll show you we can keep animations — and even static elements in place — completely uninterrupted, when navigating from page to page.

Grab the remix link from Framer Academy: https://www.framer.com/academy/lessons/framer-animations-persistent-transition-elements

Learn more about Layout Templates: https://www.framer.com/academy/lessons/framer-fundamentals-layout-templates

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

https://www.youtube.com/watch?v=kW35bBvajXg&t=27s The problem with persistent elements

https://www.youtube.com/watch?v=kW35bBvajXg&t=60s Creating a layout template

https://www.youtube.com/watch?v=kW35bBvajXg&t=130s Clean up

https://www.youtube.com/watch?v=kW35bBvajXg&t=180s Excluding elements from page effects

https://www.youtube.com/watch?v=kW35bBvajXg&t=310s Fixing the nav active state

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

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

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

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

0:00When elements are shared between pages,0:02it can still feel a bit jarring or at0:04least unnecessary for those elements to0:06transition away only to come right back0:09a moment later. Lucky for us, layout0:12templates in Framer have a trick up0:14their sleeve. In this lesson, I'll show0:16you how we can keep animations and even0:18static elements in place completely0:20uninterrupted when navigating from page0:23to page.0:27Let's recap the problem we're trying to0:28solve and then take a look at the0:30finished result that we're going for.0:32Here in the example that we finished up0:35at the end of the previous lesson, if I0:37click from page to page, you'll see that0:40the entire header bar that's at the top0:42of the page is getting pushed away only0:45to get pushed back into view, which is0:47kind of silly. This is what we might0:49call a persistent element because it was0:51there before the transition and it's0:53there after the transition. So, it0:55should really just stay put. The fact0:56that it's getting pushed out of the way0:58only to come right back into view is a1:01little disorienting and it interrupts1:03the animations with the logo on the1:04lefth hand side and it interrupts the1:07animations that should be taking place1:09between the different nav items because1:10that is in fact an animated component.1:13So, let's take a look at what it should1:15look like in the completed example. When1:18I click from home to stories, the whole1:20header bar stays put. the animations1:22remain uninterrupted and we can actually1:24see that our nav is an animated toggle.1:27The key to making this happen is layout1:30templates which we talked about in the1:32frame fundamentals course. So if you1:33haven't watched that, I'll put a link in1:35the description below. Go check that out1:37to get a more comprehensive look at what1:39layout templates are all about. But1:41because they're the key to pulling this1:42off, we're going to go and we're going1:44to create one. So, I'm just going to1:46close our completed example and head1:48back to the design canvas of our start1:50project. The easiest way to create a1:52layout template and put this whole1:54header bar in there is just to select1:56the header bar itself, rightclick it,1:59and choose create layout template.2:01That'll create our first layout template2:02and it'll put the header bar in there2:04automatically. I'm just going to name2:06this main cuz it's going to be our main2:08layout template in this project. And2:10when I click create, here we go. We get2:12our placeholder for the content that's2:14going to be on each page. We get the2:15header bar, which is where I2:17right-clicked from. So, that came over2:18automatically. And at the bottom, we2:20probably want to have our footer as well2:22because the footer is going to repeat on2:23every page. So, I'm going to leave the2:26layout template. Go back to the2:27homepage. Come down here and grab our2:30footer. And I'm just going to hit2:31command X on my Mac. That'll be control2:34X on your PC. And then to get back into2:36the layout template, I can just2:38doubleclick on the header bar since it's2:40part of the layout template. And now I2:43can just hit paste. I have the2:44breakpoint selected and hitting paste2:46drops the footer right in there. So I've2:48got the header bar. I'll have the2:49content of each page. And I've got the2:51footer at the bottom. So basically how2:53you would normally set up a layout2:55template because these elements repeat2:56on every page. You'll save yourself a2:58bit of work to establish these elements3:00in the layout template and then apply3:02the layout template to each and every3:03page. So that way if you need to make a3:05change, you can do it in one place.3:06It'll happen on every page. Again, we go3:09over that in frame fundamentals. So3:10going back to our homepage now, if we3:13look at the layers panel, we only see3:15the content of the page. We don't see3:16the header bar or the footer anymore3:19because they're part of the layout3:20template. They're sort of integral to3:22the breakpoint itself. So I'm going to3:24go to the other pages and take a look at3:27what we've ended up with. Because while3:29the other pages do in fact have our3:31layout template applied, they also still3:33have those duplicate elements. They3:36still have their own header bar, which3:37I'm going to delete. And they have their3:39own footer, which I'm going to delete3:41cuz I sure don't want two footers. And3:44then I'll go to the features page and do3:45the same thing. I'm going to delete the3:47header bar and delete the footer. So3:49that way we aren't inheriting those and3:50then inserting a duplicate on top. Cool.3:53So, let's go back to our homepage. And3:56I'm going to press command P on my Mac3:58to preview this. And you'll notice that4:00nothing has really been solved here. We4:03have the same problem that we had from4:05the very beginning. And that's because4:07there's one more step we have to do to4:09tell an element that we want to exclude4:11it from the page effect. We don't want4:13it to participate in the animated4:15transition that's taking place here. So,4:17we'll leave preview mode. I'll double4:19click on the header bar to go back into4:21the layout template. And with the header4:23bar selected, I'm going to come down4:25here to styles. And I'm going to click4:28to add a style. And you'll find here on4:30this big long list that there is a page4:33effect style. You can think of it more4:35as a property than something that's4:36stylistic. But with the page effect4:38property added, we can set it to4:41exclude, which is going to do exactly4:43what we want. So I'll go back to the4:45homepage. I'll press command P to4:46preview this. And now when we click from4:49page to page, there we go. Now we're4:52talking. This header bar element is no4:54longer participating in those page4:57effects, and therefore remains in place,4:59keeps all of its animations persistent,5:01and we get exactly the result that we're5:03looking for. But there is still one more5:05teenytiny problem, and it's that if we5:08start on a page that isn't the homepage,5:10like if we start on the stories page for5:12example, if we land on that page first,5:16you'll notice home is still in its5:18active state. And that's because in the5:21layout template, we've got this navbar5:22set to one particular variant. The5:24variant that has home highlighted. So5:27with this layout template applied to5:29every page, we get home highlighted on5:31every page. We don't want that. Let's5:33look at how to fix it. I'm going to head5:35back to the canvas. I'm going to go back5:37into the layout template and I'm going5:39to select this component. Now, when I'm5:42editing the guts of what's inside of the5:44layout template, I can of course change5:46the variant on the properties panel5:48here. But when I'm looking at a5:49particular page that the layout template5:50is applied to, all this stuff is kind of5:53encapsulated almost like it's one5:55gigantic component. So just like we5:57would with components, we can add a6:00variable to make this property6:02accessible from the outside of the6:05component, from the outside of the6:07layout template. So let's do that. I'll6:09select my nav component. The variant is6:11the thing that I would like to expose6:12from the outside. So I'm going to click6:14on the word variant. I'm going to choose6:16to create a variable out of that. And6:18now we'll just give the variable a name.6:20I want to give it a name that's going to6:22make sense to me later. So I'm just6:24going to name it nav because nav variant6:261, nav variant 2, nav variant 3, that's6:28enough information that I think I'll be6:30able to make sense of this later. And6:32then when I head back to the stories6:34page, for example, now with the page6:36breakpoint selected, we see the6:38properties of our layout template which6:40now include the nav variable that we6:43just created. So for this page, we can6:45switch to variant three, which is where6:47features is highlighted, or we can6:48switch to variant two, where stories is6:51highlighted. And since we're currently6:52looking at the stories page, that's the6:54one we want. And then we'll switch to6:56the features page, and do the same6:58thing. We'll select the breakpoint over7:00here on the properties of the layout7:01template. We've got our nav variable,7:03which we can switch from variant one to7:05variant 3, which is the one that has7:08features highlighted. So now, no matter7:10which page a visitor initially lands on,7:13they're going to see the correct nav7:14item selected. And there you have it.7:17Persistent animations give our site a7:19sense of stability and continuity.7:22Layout templates make it possible and7:24keep global elements feeling as unified7:26as they should be. That's it for this7:28one. I'll see you 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.