Movement Paths – Previous, Current and Future

The flexibility to animate alongside a movement path is a extremely helpful factor to have in your SVG animation toolkit. Let’s discover just a few methods to realize this, together with the upcoming CSS movement path module and the newly launched GSAP3.

From our weekly sponsor: Design each a part of your web site with the model new Divi Theme Builder. Attempt it without cost.

Making animations that “really feel proper” might be difficult.

After I’m caught, I discover Disney’s 12 ideas of animation helpful. They’re from the e book ‘The Phantasm of Life’ and though the e book was written about hand-drawn character animation, numerous the ideas are related for animation on the net.

The seventh precept of animation is about arcs:

Most pure motion tends to comply with an arched trajectory, and animation ought to adhere to this precept by following implied “arcs” for better realism.

In different phrases, animating alongside a curved path could make motion really feel extra real looking.

Straight strains are what browsers do greatest although. After we animate a component from one place to a different utilizing a translation the browser doesn’t take realism under consideration. It’ll at all times take the quickest and best route.

That is the place movement paths can come in useful. Movement paths give us the flexibility to maneuver a component alongside a predefined path. They’re nice for creating trajectories to animate alongside.

Use the toggle to see the paths.

See the Pen Alien Abduction- toggle by Cassie Evans (@cassie-codes) on CodePen.default

In addition to being helpful, they’re numerous enjoyable to mess around with.

See the Pen Loop by Cassie Evans (@cassie-codes) on CodePen.default

So, how do you animate alongside a movement path?

I exploit GreenSock (GSAP) for many of my SVG animation and I made these demos utilizing the newly launched GSAP three and their MotionPathPlugin. So, if you wish to skip to that bit, go forward!

In any other case let’s take somewhat journey via the previous, current and way forward for movement path animation.

(Did somebody say CSS movement paths?)

First, somewhat setup tip.

Make sure that to maintain the trail and component you’re animating in the identical SVG and co-ordinate house, in any other case issues get a bit messy.


In the event you google “SVG movement path animation”, you’re going to get numerous hits speaking about SMIL.

SMIL was the unique proposed methodology for SVG animation. It included the flexibility to animate alongside a path utilizing the component.

It’s good and declarative and at the moment the browser assist is surprisingly good, masking all trendy browsers besides Edge and Opera Mini.

However, and it is a massive however, the way forward for SMIL is unsure, and has been for some time.

It was deprecated by Chrome just a few years again and though they’ve now suspended that deprecation, implementations nonetheless range and there’s no clear path in direction of cross-browser assist.

Though it’s enjoyable to mess around with, SMIL isn’t very future-proof, so I’m solely going to the touch on it.

With the intention to animate alongside a path with the animateMotion component, you reference the trail you need to animate alongside utilizing path=”…” and outline the component you need to animate utilizing xlink:href=”#…”:

See the Pen loop SMIL by Cassie Evans (@cassie-codes) on CodePen.default

With SMIL successfully out of the image, browser distributors are actually centered on supporting trendy alternate options just like the CSS Movement Path Module.

CSS Movement Path Module

Consideration: As of the time of writing, the examples on this part are experimental and greatest considered in Chrome.

You possibly can take a look at which options your browser helps within the demo under.

See the Pen Browser Help – CSS movement path module by Cassie Evans (@cassie-codes) on CodePen.default

In the event you’ve bought all inexperienced smiley faces, you’re good to go. However you might have a tragic face for offset-anchor. It’s because this property is at the moment nonetheless experimental. It’s behind a flag in Chrome, which means it’s not turned on by default.

You possibly can select to allow it by going to this URL in Chrome:


and enabling experimental net platform options.

This module is joint work by the SVG and CSS working teams, so not like SMIL, we’ll have the ability to use CSS movement paths to animate each, HTML and SVG DOM components. I like a CSS-only resolution, so though it’s not prepared to make use of in manufacturing (but), that is fairly thrilling stuff.

The movement path module consists of 5 properties:

offset (shorthand property for the next)


offset-path defines the trail that we will place our component on. There are just a few proposed values however path() appears to be the one one supported proper now.

offset-path: path(‘M1345.7 2.6l2.Four-Four.Four’);

path() takes a path string with SVG coordinate syntax, which can look scary, however you don’t have to jot down this out. You possibly can create a path in a graphics enhancing program and duplicate and paste it in.


offset-distance specifies the place alongside an offset-path for a component to be positioned. This may be both in pixels or as a share of the size of the trail.

See the Pen Rocket – CSS movement path – offset-distance by Cassie Evans (@cassie-codes) on CodePen.default


By default the component’s prime left nook can be aligned with the trail, however we will change this with offset-anchor.
offset-anchor behaves rather a lot like transform-origin. Actually if set to auto, it’s given the identical worth because the component’s transform-origin, so we will optionally use transform-origin for a similar outcomes.

Like transform-origin it accepts a place with x and y values, both as a share or a key phrase like backside or left.

Have a play with the values:

See the Pen Rocket – CSS movement path – offset anchor by Cassie Evans (@cassie-codes) on CodePen.default


offset-rotate defines the route the component faces on the trail.

By default it’s set to auto and can rotate with the trail. You possibly can cross in an optionally available second worth in levels so as to tweak the route of this rotation.

See the Pen Rocket – CSS movement path – offset-rotate – auto deg by Cassie Evans (@cassie-codes) on CodePen.default

If you’d like your component to face the identical route all through, and never rotate with the trail, you possibly can miss auto and cross in a price in levels.

See the Pen Rocket – CSS movement path – offset-rotate – deg by Cassie Evans (@cassie-codes) on CodePen.default

These properties had been renamed from movement to offset since this spec was proposed. It’s because alone, these properties simply present one other solution to set the place and rotation of completely positioned components. However we will create movement by utilizing them along with CSS animations and transitions.


@keyframes transfer

See the Pen Rocket – CSS movement path by Cassie Evans (@cassie-codes) on CodePen.default

Consideration: SVG transform-origin quirks.

On this demo, I’m utilizing a comparatively new CSS property, transform-box.

That is to keep away from a browser quirk that’s caught me out just a few instances. When calculating transforms and transform-origin, some browsers use the component’s bounding field because the reference field and others use the SVG viewbox.

In the event you set the worth to fill-box the objects bounding field is used because the reference field.

And if you happen to set the worth to view-box the closest SVG viewbox is used because the reference field.

You possibly can see what occurs to the middle of rotation once we change it right here:

See the Pen Rocket – CSS movement path – transform-box by Cassie Evans (@cassie-codes) on CodePen.default

GreenSock Animation Platform (GSAP)

Whereas we look forward to the CSS resolution to be extra broadly applied we’re in a little bit of a movement path limbo. Fortunately there’s some JavaScript animation libraries which might be bridging this hole.

I normally use GreenSock for SVG animation for just a few causes.

There are some cross browser quirks with SVG, particularly with how transforms are dealt with. The oldsters at GreenSock go above and past to deal with these inconsistencies.

Animation can be a bit fiddly, particularly in the case of fine-tuning timings and chaining completely different animations collectively. GreenSock provides you numerous management and makes creating complicated animations enjoyable.

In addition they present some plugins which might be nice for SVG animation like DrawSVG, MorphSVG and MotionPathPlugin.

They’re all free to experiment with on Codepen, however a few of the plugins are behind a membership charge. MotionPathPlugin is among the free ones, and a part of the brand new GSAP three launch.

MotionPathPlugin provides you the flexibility to show an SVG path right into a movement path, or specify your individual path manually. You possibly can then animate SVG or DOM components alongside that path, even when these components are in a very completely different coordinate house.

Right here’s a demo with the required libraries added to start out you off.

With the intention to use a plugin we have now to register it, like this:


Then we will begin animating. That is what a tween utilizing the simplified GSAP three syntax appears like:“.rocket”,
motionPath: …
period: 5,

The identify ‘tween’ comes from the world of hand-drawn animation, too.

Tweening is the method of producing intermediate frames between two pictures to present the looks that the primary picture evolves easily into the second picture.

That’s just about what a GSAP tween does. You feed within the component you need to animate, the period, and the properties you need to goal and the tween will work out the in-between states.

The motionPath attribute can be utilized shorthand, and handed a path:“.rocket”,
motionPath: “#path”,
period: 5,

Or, if we wish extra management over the settings we will cross it an object of choices:“.rocket”,
motionPath: ,
period: 5,

See the Pen Rocket – GSAP movement path by Cassie Evans (@cassie-codes) on CodePen.default

Listed here are a few of the properties we will management.


This defines the movement path we’re animating alongside, we will reference a path that exists within the doc by utilizing a selector,


a string that accommodates SVG path knowledge,


an object containing an array of x and y co-ordinates to maneuver between,

path: [, x: 300, y: 20]

or a variable referring to one in all these choices:

const myPath = ‘M125.7 655a9.Four 9.Four…’



We will use this to align the component to the trail, or different components within the doc by passing in a selector:


We will additionally align the component to itself if we wish the animation to start out from the component’s present place.


Within the subsequent demo, the purple rocket is aligned to self and the inexperienced rocket is aligned to the trail.

align: “self” is like shifting the trail to the component, quite than the component to the trail.

See the Pen Rocket – GSAP movement path – align by Cassie Evans (@cassie-codes) on CodePen.default

By default, the component’s prime left nook would be the heart of rotation and alignment. With the intention to align the component precisely on the trail you’ll must set the component’s heart of rotation, like this:

gsap.set(“.rocket”, );


That is how we get our component to rotate together with the curvature of the trail:


We will additionally present a quantity worth. It will rotate together with the trail, however preserve that angle relative to the trail.


begin & finish

These properties allow us to outline the place on the trail the movement ought to start and finish.

By default, it begins at zero and ends at 1, however we will present any decimal quantity:

path: “#path”,
align: “#path”
autoRotate: true,
begin: zero.25,
finish: zero.75,

If you’d like the component to go backwards alongside the trail, you possibly can present destructive numbers.

See the Pen Rocket – GSAP movement path – align by Cassie Evans (@cassie-codes) on CodePen.default


In case your component is beginning off at a distinct place within the doc and also you need it to align with the trail you may discover a soar because it strikes from its place to the trail.

See the Pen Rocket – GSAP movement path – align by Cassie Evans (@cassie-codes) on CodePen.default

You possibly can repair drive it to render instantly upon instantiation by including immediateRender:true to the tween.

// animate the rocket alongside the trail“.rocket”,
path: “#path”,
align: “#path”,
autoRotate: true,
period: 5,
ease: “power1.inOut”,
immediateRender: true,


One other tremendous cool characteristic of the GSAP three launch is the MotionPathHelper.

It lets you edit paths instantly within the browser! I discovered this actually useful, as I’m at all times going forwards and backwards between the browser and my graphics editor.

Give it a go within the demo under. Once you’re performed, click on “copy movement path” to repeat the SVG path knowledge to your clipboard. Paste the brand new path knowledge into the d=”” attribute within the SVG code to replace your path.

There are directions on find out how to edit the trail within the GSAP docs.

See the Pen Rocket – GSAP movement path – helper by Cassie Evans (@cassie-codes) on CodePen.default

GreenSock is a ton of enjoyable to mess around with!

There are a bunch of different options and plugins that when paired with movement path animation can be utilized to create actually cool results.

On this demo, DrawSVG is progressively exhibiting the textual content path as some staggered components animate alongside the trail utilizing MotionPathPlugin:

See the Pen Squiggle textual content animation by Cassie Evans (@cassie-codes) on CodePen.default

In the event you’ve had enjoyable with these examples and need to discover GreenSock some extra, Christina Gorton has written The New Options of GSAP three offering a sensible overview.

GreenSock even have an excellent getting began information.

Glad animating!

Making a Distorted Masks Impact on an Picture with Babylon.js and GLSL

Superior Demos Roundup #11

Leave a Reply