Animations

Using the Drag Effect in Framer (Animation Lesson 5)

Using the Drag Effect in Framer (Animation Lesson 5)

Using the Drag Effect in Framer (Animation Lesson 5)

Joseph

·

5:34

·

15K views

·

About this lesson

The drag effect lets visitors reach right in and grab elements on the page — by making elements physically moveable in the browser. It might be more playful than functional — but one things for sure — it’s fun. In this lesson, I’ll show you how to make any element draggable with just a couple of clicks.

Grab the remix file: https://www.framer.com/academy/lessons/framer-animations-drag-effect

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

https://www.youtube.com/watch?v=lbYuJzFfmXE&t=7s What is the drag effect?

https://www.youtube.com/watch?v=lbYuJzFfmXE&t=28s Setting up drag interactions

https://www.youtube.com/watch?v=lbYuJzFfmXE&t=48s Restricting drag directions

https://www.youtube.com/watch?v=lbYuJzFfmXE&t=67s Using boundaries

https://www.youtube.com/watch?v=lbYuJzFfmXE&t=87s Adding elasticity and momentum

https://www.youtube.com/watch?v=lbYuJzFfmXE&t=112s Final tips and wrap-up

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

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

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

0:00The drag effect lets visitors reach0:02right in and grab elements on the page0:04by making elements physically movable in0:06the browser. It might be more playful0:09than functional, but one thing's for0:11sure, it's fun. In this lesson, I'll0:14show you how to make any element0:15dragable with just a couple of clicks.0:18[Music]0:21For this one, again, we're going to be0:23using that same project file that we0:24used for the previous couple of lessons.0:26So, head to framer.com/academy.0:29if you're not there already and grab the0:31remix link from the description below0:33this video. So, here in this project,0:35we've got our examples down below. We've0:37already knocked out the first three and0:38now we're on to the fourth. And what I0:41want to do here is make this element0:44dragable. So, with it selected, I'm0:46going to head over to the properties0:47panel, scroll down to effects, and click0:50to add the drag effect. And in the drag0:52effect model, naturally, we get some0:54settings here. And we'll go through each0:56of these one at a time. The first one0:58being free form. Do we want to allow the1:00visitor to drag this element around1:03wherever they want or do we want it to1:04be constrained? I'm going to leave it on1:06free form for now. We're going to1:07preview this and then we'll go back and1:09look at the alternative. But with it set1:12to free form, we can decide whether or1:13not we want it to snap back to its1:15original position when we release the1:16cursor. I'm going to leave it on1:18snapback. And let's just preview this to1:20see what the defaults look like. I'll1:22press command P on my Mac. Scroll down1:24here. And there we have it. This thing1:26is dragable and when I let go, it1:29returns back to its original position.1:31And that is because of that snapback1:33setting set to yes. If I set this to no1:36and preview once again, you'll see that1:38I can just drag this wherever I want. I1:41can just place it, including outside of1:43the bounds of this frame that it's1:44inside of. And the overflow is set to1:46hidden. So when I drag beyond those1:48bounds, uh, we actually can't even see1:50it anymore. And we're allowed to do that1:51because again, we have it set to free1:53form. And that's how free form works.1:55But let's go back and fiddle with some1:57of these settings here. You may have1:58noticed that when I switch snapback to2:00no, we got this new setting called2:03momentum. And with momentum turned on,2:05now if I go and preview this, when I2:07click and drag, if I release before I2:09stop moving my cursor, you'll see it2:11flew away. There's some momentum there.2:14There's some inertia transferred into2:15the object and it carries. It continues.2:18If you have snapback turned on, you2:20don't get that because it's just going2:21to return back to its original position.2:23you instead get to choose an easing2:25curve for how it snaps back into its2:28original position. But let's look at the2:30alternative to free form real quick. I'm2:32going to come back here and set free2:34form to no. And when free form is set to2:36no, we get to choose a section on the2:39page that's going to behave as a2:40container, sort of like a boundary that2:42the dragable object can't go outside of.2:45So we don't have any sections on this2:46page. So, the first thing I'm going to2:48do is select the frame that I want to2:50behave as the container, as the2:52boundaries, which is this frame here.2:54And I'm going to come down to the bottom2:56of the properties panel and add a scroll2:58section. By adding a scroll section, I3:01can now declare a name for this. And3:03then we can choose that name when we're3:05determining what bounds our dragable3:08layer should stay within. So, again,3:10back over to the drag effect modal. And3:11now, when we go to choose a section,3:13there's that drag frame section that I3:15just created. And then I'll leave3:17momentum turned on so I can chuck this3:19thing around. And you'll notice now3:21unlike when we had free form set to yes,3:23we can now choose to turn on momentum3:25and have a transition. And the3:28transition is because we have a3:30boundary. And when the object gets3:31dragged to the boundary or the momentum3:33hits that boundary, it's going to come3:36back. It's going to stay within the3:37boundary. So that transition sort of3:39determines what that motion looks like.3:42And I'm just going to stick with the3:43default spring for now. And again, I'll3:45hit command P on my Mac to preview. And3:47we'll see what this looks like. There we3:50go. A little bit of momentum. And look3:52at that. It bounces off the edge. It's3:54staying within this container. We don't3:56have to worry about it completely flying3:58into oblivion. And the only thing we4:00really do have to worry about is when it4:02gets into these corners, it gets a4:03little bit cut off because the corner4:05radius of this frame is larger than the4:07radius of the circle. But we can easily4:09fix that by either increasing the radius4:11of the square or we can just set the4:13overflow to visible instead of hidden.4:16And now when we preview this, rather4:18than getting clipped, the dragable layer4:20is allowed to kind of pop out. It's just4:23getting clipped at the bottom and the4:24right. And that's because the frame4:26wrapped around this still has the4:28overflow set to hidden. So if we wanted4:29to, we could go back, press the escape4:31key to select the parent. We could also4:33rightclick on this, go to overflow, set4:36that to visible. And for good measure,4:38I'll press escape one more time just to4:40double check, make sure there's not4:41another parent frame that's clipping4:43this. And this could be. So, we'll go4:45and set the overflow from hidden to4:48visible on this as well. And then escape4:50one more time. Looks like we're good. I4:52don't think we have any other frames4:54that are at risk of clipping this. So,4:56again, command P on my Mac. Go into4:57preview mode. And now, there we go.5:00There's nothing around the sides of this5:03that's going to clip it anymore. So, we5:05don't have that issue in the corners and5:07we don't have the issue of this flying5:09off into oblivion. And there you have5:11it. With drag effects, visitors can take5:14control, literally. It's a small feature5:16that opens up fun possibilities for more5:18playful, tangible sites. That's it for5:21this one. 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.