Skip to main content
GSAP Animation TutorialArticle 28

GSAP MotionPath Tutorial: Move Elements Along SVG Paths

Turn an SVG path into a route, align a traveler, rotate it with every bend, coordinate development workflows and connect path progress to scrolling.

GSAP MotionPath Tutorial Move Elements Along SVG Paths - NavTechSolution

MotionPathPlugin answers “where should this element travel?” GSAP duration, easing, timelines and ScrollTrigger answer how and when it moves. Unlike DrawSVG from Article #27, MotionPath does not reveal the stroke—it moves a target along it.

1. What Is MotionPathPlugin?

MotionPathPlugin lets GSAP move an HTML or SVG target along a supported path. For a dependable beginner workflow, use an inline SVG path and keep the traveler in the same responsive SVG coordinate system introduced in the SVG animation tutorial, Article #26.

MotionPath mental model showing SVG route, traveler and path-based movement
PATH = route. ELEMENT = traveler. MOTIONPATH = movement along the route.

2. DrawSVG vs MotionPath

DrawSVG

Reveals the path stroke.

MotionPath

Moves an object along the path.

Together

A coordinated timeline can draw first and then move.

DrawSVG reveals a route while MotionPath moves a traveler
DrawSVG and MotionPath solve different problems; a timeline coordinates them.

3. Plugin Setup

This site uses GSAP 3.13.0. The page loads the matching 3.13.0 MotionPathPlugin after core, then the matching ScrollTrigger file used by the scoped scroll demo. Each script appears once.

<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/MotionPathPlugin.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/ScrollTrigger.min.js"></script>

gsap.registerPlugin(MotionPathPlugin, ScrollTrigger);

4. First MotionPath Demo

MotionPath timeline ready.

5. First Animation

gsap.to(traveler, {
  duration: 4,
  ease: "none",
  motionPath: { path: route, align: route, alignOrigin: [0.5, 0.5] }
});

6. Understanding path

path defines the route. It can receive the scoped SVG path node directly, avoiding collisions with another diagram.

7. Straight, Curve and Wave Paths

8. Why ease: "none" Is Useful

Constant timing makes technical travel easy to read. Normal GSAP eases from Article #7 still work: they change timing along the route, not its geometry.

9. Easing Playground

CURRENT: none

10. autoRotate

With autoRotate: true, an arrow or rocket turns to follow the path tangent. Without it, the target keeps its own orientation.

WITHOUT → → → →WITH → ↗ ↑ ↘ →

11. autoRotate Visual

The visual orientation changes; the route geometry does not.

12. autoRotate Demo

autoRotate: true

13. The Alignment Problem

A target can appear offset when its own coordinate space and the route are not coordinated. align maps the target to the path while alignOrigin chooses which point on the target sits there.

14. align

motionPath: {
  path: route,
  align: route
}

15. alignOrigin

[0, 0][0.5, 0.5][1, 1]

16. Alignment Playground

CURRENT: [0.5, 0.5]

17. Start and End

Normalized route progress uses 0 for the beginning and 1 for the end. start: 0.25, end: 0.75 travels only through the middle half.

18. Path Progress Graphic

00.250.50.751

19. Start/End Playground

start: 0, end: 1

20. Reverse Motion

start: 1, end: 0 defines backward route direction. tween.reverse() instead reverses the current playback from its playhead.

21. Looping Motion

repeat: -1ease: "none"

Reserve infinite travel for small decoration and stop it for reduced-motion users.

22. Yoyo

repeat: 1, yoyo: true plays START → END → START. Yoyo changes playback, not the SVG path.

23. MotionPath + Timeline

Build on the timeline model from Article #10, reuse the player controls from Article #11, and place overlaps with the position parameter from Article #12.

const tl = gsap.timeline({ paused: true });
tl.from(title, { opacity: 0, y: 20 })
  .to(traveler, { duration: 3, motionPath: {
    path: route, align: route, alignOrigin: [0.5, 0.5], autoRotate: true
  }});

24. Timeline Checkpoints

STARTDESIGNBUILDTESTDEPLOY

25. Development Workflow Demo

PLANDESIGNCODETESTDEPLOY

26. MotionPath + DrawSVG

DrawSVG can reveal the route and MotionPath can then move the traveler. This page keeps the example conceptual rather than loading a second premium plugin solely for one demo.

tl.from(route, { drawSVG: "0%", duration: 1.5 })
  .to(traveler, { duration: 3, motionPath: { path: route, align: route } });

27. Draw and Follow Together

A traveler does not automatically follow the currently visible stroke. Coordinate both tweens on the same timeline when they must appear synchronized.

28. MotionPath + ScrollTrigger

This example extends the scoped trigger pattern from the ScrollTrigger tutorial, Article #14.

gsap.to(traveler, {
  ease: "none",
  motionPath: { path: route, align: route, alignOrigin: [0.5, 0.5], autoRotate: true },
  scrollTrigger: { trigger: section, start: "top 80%", end: "bottom 20%", scrub: true }
});

29. Scroll-Driven Traveler

SCROLL THROUGH THIS ROUTE

STARTDESIGNBUILDDEPLOY

30. Scrub Mental Model

SCROLL PROGRESS 100%MOTION PATH END

With linear easing and the scrub model from Article #16, animation progress follows scroll progress. Perceived geometric speed can still vary with path shape.

31. ScrollTrigger Start and End

ScrollTrigger start/end from Article #15 define viewport positions. They do not select a portion of the route.

32. Two Different Start/End Systems

MOTIONPATHstart: 0
end: 1

Where on the path.

SCROLLTRIGGERstart: "top 80%"
end: "bottom 20%"

Where scroll control begins and ends.

33. Multiple Travelers

A timeline or stagger from Article #6 can offset travelers without creating separate timer logic.

34. Convoy Demo

123

35. Different Paths

Frontend, backend and database packets can each own a route and tween. Scope each selector to its diagram so repeated SVG classes never collide.

36. Technical Architecture Demo

USERFRONTENDAPIDATABASE

37. API Request Animation

USERFRONTENDAPIDATABASE

Ready. Educational sequence, not real network timing.

38. GSAP MotionPath Lab

NAVTECHSOLUTION

Control How an Element Travels Along an SVG Path

Path
Auto rotate
Path
Curve
Start / End
0 → 1
Auto rotate
true
Align origin
[0.5, 0.5]
Duration
2s
Ease
none

39. Main Lab Controls

Every control maps to a supported MotionPathPlugin 3.13.0 value and rebuilds only this lab’s tween.

40. Main Lab Status

The status cards show the actual configuration used for the current lab tween.

41. Generated Code

The code preview is written with textContent, so control values are never interpreted as HTML.

42. Main Lab Lifecycle

function destroyLabTween() {
  if (labTween) labTween.kill();
  labTween = null;
  gsap.killTweensOf(labTraveler);
}

43. Safe Reset

The lab kills only its traveler tween. It never uses gsap.killTweensOf("*") and never destroys unrelated ScrollTriggers.

44. MotionPath Project: Development Journey

NAVTECHSOLUTION

DEVELOPMENT JOURNEY

NavTechSolution development journeyIdea, design, develop, test, deploy and grow stages connected by a responsive route.
IDEADESIGNDEVELOPTESTDEPLOYGROW

Journey ready.

45. Project Animation

One timeline advances the traveler and stage highlights from IDEA to GROW; no random timers are used.

46. Project Scroll Version

The large project remains button-controlled for stability on small screens. The smaller route above demonstrates scrub without pinning the article.

47. MotionPath and Responsive SVG

A stable viewBox plus width: 100%; height: auto preserves the shared route and traveler coordinate system as the graphic scales.

48. Responsive Alignment

DESKTOPsame viewBoxTABLETsame viewBoxMOBILEsame viewBox

These demos keep each traveler and path inside the same SVG, so uniform CSS scaling preserves their internal coordinates. If a breakpoint actually changes path geometry or moves the target into another coordinate space, rebuild or invalidate only that tween after layout; do not repeatedly recalculate alignment on every animation tick.

49. Mobile Strategy

Controls wrap into touch-friendly rows, code scrolls inside its block, labels stay outside the route where practical and the large journey remains in normal page flow.

50. Performance

Cost depends on traveler count, path complexity, active tweens, filters, shadows, DOM size, ScrollTrigger usage and device performance. Test the actual composition rather than assuming one technique is always faster.

51. Preferred Animation Properties

MotionPath primarily produces transform-based movement. Avoid stacking large blur, complex SVG filters and massive animated shadows on many travelers.

52. Accessibility

Motion never carries workflow meaning by itself: stage labels remain readable, meaningful SVGs have labels, controls are real buttons and status changes use restrained live regions.

53. Reduced Motion

When prefers-reduced-motion: reduce matches, long travel and scrub are skipped, looping is disabled and travelers are placed at a meaningful static endpoint while all labels remain visible.

54. Progressive Enhancement

Routes, stages and travelers render without JavaScript. JavaScript only enhances their state after GSAP and both required plugins load successfully.

55. Common MotionPath Mistakes

Plugin not loadedPlugin not registeredGSAP/plugin mismatchWrong path selectorPath does not existTraveler not scopedMissing alignmentWrong alignOriginautoRotate not enabledTwo start/end systems confusedUnexpected path directionTraveler offsetFixed SVG without viewBoxOld lab tween still runningGlobal tween cleanupExcessive infinite loopsMobile layout ignoredReduced motion ignoredDrawSVG syntax used hereExpecting MotionPath to draw

56. MotionPath Not Working?

  1. GSAP loaded?
  2. MotionPathPlugin loaded?
  3. Plugin registered?
  4. Versions compatible?
  5. Traveler exists?
  6. SVG path exists?
  7. Correct scoped selector?
  8. Valid path geometry?
  9. align correct?
  10. alignOrigin correct?
  11. autoRotate expected?
  12. start/end valid?
  13. Old tween running?
  14. ScrollTrigger controls same tween?
  15. SVG viewBox present?
  16. Reduced motion active?
  17. Console errors?

57. MotionPath vs DrawSVG

ToolResponsibility
MotionPathMoves a target along a route.
DrawSVGReveals an SVG stroke.
ScrollTriggerConnects animation to scroll.
TimelineControls sequencing.
StaggerOffsets multiple animations.

58. Quick Reference

FeatureExamplePurpose
Motion pathmotionPath: {...}Move target along route
Pathpath: routeChoose route
Alignalign: routeCoordinate target/path space
Align origin[0.5, 0.5]Choose target alignment point
Auto rotatetrueRotate with direction
Start0Route start progress
End1Route end progress
Reverse route1 → 0Travel backward
Ease"none"Control timing
Timelinegsap.timeline()Sequence path motion
ScrollTriggerscrub: trueConnect travel to scroll

59. Cheat Sheet Graphic

GSAP MotionPath path align alignOrigin autoRotate start end and scrub cheat sheet
A compact production reference for the options used throughout this tutorial.

60. Final Mental Model

SVG PATHROUTE+TARGETTRAVELERMotionPathPluginALIGN + ROTATETIMELINE / SCROLL

MotionPathPlugin answers “where should this element travel?” GSAP answers “how and when should it move?”

61. Preview Blog #29

Coming next

GSAP MorphSVG Tutorial: Morph One SVG Shape Into Another

Next we will explore compatible shapes, path conversion, shapeIndex, timelines, responsive SVG and accessible reduced-motion fallbacks. The link will be added only after Article #29 exists.

Frequently Asked Questions

What is GSAP MotionPathPlugin?

MotionPathPlugin moves a GSAP target along a path. This tutorial focuses on routes defined by inline SVG paths.

How do I register MotionPathPlugin?

Load the same version as GSAP core, then call gsap.registerPlugin(MotionPathPlugin).

Can GSAP move an element along an SVG path?

Yes. Pass an inline SVG path element or selector to the motionPath path property.

What does path do in MotionPathPlugin?

The path property identifies the route that the target follows.

What does align do?

Align maps the target into the path coordinate space so it sits on the route as expected.

What does alignOrigin do?

alignOrigin selects the normalized point on the target used for alignment, such as its center at [0.5, 0.5].

What does autoRotate do?

autoRotate turns the target to follow the direction of the path as it travels.

How do I move only part of a path?

Set normalized start and end values, such as start: 0.25 and end: 0.75.

Can MotionPath move backward?

Yes. Use start: 1 and end: 0 for reverse route direction, or reverse a tween to reverse playback.

Can I use easing with MotionPath?

Yes. Easing changes timing along the route; it does not change the path geometry.

Can I use MotionPath with a GSAP timeline?

Yes. A timeline can sequence path travel with headings, stages and other interface animation.

Can MotionPath work with DrawSVG?

Yes. They are separate tools: DrawSVG reveals a stroke while MotionPath moves a target along a route.

Can MotionPath work with ScrollTrigger?

Yes. ScrollTrigger can start a MotionPath tween or connect its progress to scrolling with scrub.

Can I control MotionPath with scroll?

Yes. Add a scoped ScrollTrigger configuration with scrub to the MotionPath tween.

What is the difference between MotionPath and DrawSVG?

MotionPath moves a target; DrawSVG changes which portion of an SVG stroke is visible.

Why is my object offset from the SVG path?

Check that path and target are scoped correctly, then use align and the appropriate alignOrigin.

Can MotionPath work responsively?

Yes. A stable SVG viewBox and responsive CSS preserve the shared coordinate system as the graphic scales.

Can I use MotionPathPlugin on a PHP website?

Yes. PHP renders the markup and scoped vanilla JavaScript runs GSAP in the browser.