Skip to content
animorio
IT
Back to the library

Golf hole flyover

Images, ScrollGSAP, CSS onlyAdvancedCompressed weight: Demo 14 KBGSAP + ScrollTrigger 45 KBFreeDownload the zip

Scroll inside the preview

The page of hole 7 at Sable Pines, a made-up desert golf club, on warm paper: as you scroll a real aerial photo of the golf course opens from its middle and the hole is played over it. The flight of the drive draws itself from the tee in orange with the ball rising above its own shadow, a thin ring marks where it lands and a chip counts the yards; then the approach onto the green, the flag rising and waving, the putt rolling in. Beside it the hole card rolls par, yards and handicap, the yards to the pin roll down after every shot and at the end the score is circled: birdie.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Golf hole flyover" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Sable Pines, hole 7 played as you scroll</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/index.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/instrument-sans@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the page of one hole at Sable Pines, a made-up desert golf club. Scrolling down, the stage stays still: an aerial
       photo of the hole opens from its middle, then the round is played over it. The flight of the drive draws itself
       from the tee with the ball arcing above its shadow, a thin ring marks where it lands and a chip counts the yards;
       the approach follows onto the green, the flag rises and waves, the putt rolls in. Beside it the hole card rolls
       its figures (par, yards, handicap, yards to the pin) and at the end the score is circled: a birdie -->
  <header class="barra">
    <p class="marchio">
      <svg class="marchio__segno" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 21V3.5l10 4-10 4" /><path d="M3.5 21h14" /></svg>
      Sable Pines
    </p>
    <nav class="barra__voci" aria-label="Main">
      <a href="#" aria-current="page">The course</a>
      <a href="#">Membership</a>
      <a href="#">Tee times</a>
    </nav>
  </header>

  <main>
    <section class="apertura">
      <p class="piccolo">Sable Pines Golf Club, the desert course</p>
      <h1 class="titolo">Hole 7, <em>the Lone Pine.</em></h1>
      <p class="piccolo piccolo--tenue">
        Scroll to play the hole
        <svg class="giu" viewBox="0 0 12 16" aria-hidden="true"><path d="M6 1v13M1.5 9.5 6 14l4.5-4.5" /></svg>
      </p>
    </section>

    <section class="buca" data-buca>
      <div class="palco">
        <div class="scena">
          <figure class="lastra" data-lastra>
            <i class="lastra__ombra" data-ombra aria-hidden="true"></i>
            <div class="lastra__maschera" data-maschera>
              <div class="lastra__camera" data-camera>
                <img class="lastra__foto" src="fairway.webp" alt="Aerial view of the hole: a fairway curving between desert sand and pines to a green guarded by a bunker" width="1024" height="576" decoding="async">
                <i class="lastra__luce" aria-hidden="true"></i>
                <i class="lastra__grana" data-grana aria-hidden="true"></i>

                <svg class="tiro" data-tiro viewBox="0 0 1024 576" aria-hidden="true">
                  <defs>
                    <mask id="traccia-drive" maskUnits="userSpaceOnUse"><path data-scopri d="" fill="none" stroke="#fff" /></mask>
                    <mask id="traccia-approccio" maskUnits="userSpaceOnUse"><path data-scopri d="" fill="none" stroke="#fff" /></mask>
                    <mask id="traccia-putt" maskUnits="userSpaceOnUse"><path data-scopri d="" fill="none" stroke="#fff" /></mask>
                    <filter id="morbida" x="-1" y="-1" width="3" height="3"><feGaussianBlur stdDeviation="2.2" /></filter>
                  </defs>

                  <!-- the ground under each flight, dashed, uncovered by its mask as the ball passes -->
                  <path class="tiro__terra" data-terra mask="url(#traccia-drive)" d="" />
                  <path class="tiro__terra" data-terra mask="url(#traccia-approccio)" d="" />
                  <path class="tiro__terra tiro__terra--putt" data-terra mask="url(#traccia-putt)" d="" />

                  <!-- the flights: a soft dark halo under the accent line, so it reads on grass and on sand -->
                  <path class="tiro__alone" data-alone d="" pathLength="1" />
                  <path class="tiro__alone" data-alone d="" pathLength="1" />
                  <path class="tiro__volo" data-volo d="" pathLength="1" />
                  <path class="tiro__volo" data-volo d="" pathLength="1" />

                  <!-- the tee and the two landings: thin rings, each with a ripple that leaves once -->
                  <g data-segno="tee"><circle class="tiro__onda" data-onda /><circle class="tiro__anello tiro__anello--tee" data-anello /></g>
                  <g data-segno="drive"><circle class="tiro__onda" data-onda /><circle class="tiro__anello" data-anello /></g>
                  <g data-segno="approach"><circle class="tiro__onda" data-onda /><circle class="tiro__anello" data-anello /></g>

                  <!-- the cup and the flag -->
                  <ellipse class="tiro__buca" data-coppa />
                  <g class="bandiera" data-bandiera>
                    <line class="bandiera__asta" data-asta />
                    <path class="bandiera__telo" data-telo d="" />
                  </g>

                  <!-- the ball, with its shadow on the ground -->
                  <ellipse class="tiro__ombra" data-ombra-palla filter="url(#morbida)" />
                  <g data-palla><circle class="tiro__palla" data-r-palla /><circle class="tiro__lucepalla" data-r-luce /></g>
                </svg>

                <p class="chip chip--tee" data-chip="tee"><span>Tee</span></p>
                <p class="chip" data-chip="drive"><span>Drive</span><b><span data-conta>0</span> yd</b></p>
                <p class="chip" data-chip="approach"><span>Approach</span><b><span data-conta>0</span> yd</b></p>
                <p class="chip chip--putt" data-chip="putt"><span>Putt</span><b><span data-conta>0</span> ft</b></p>
              </div>
            </div>
            <i class="lastra__bordo" aria-hidden="true"></i>
          </figure>

          <aside class="scheda" data-scheda aria-label="Hole card">
            <p class="scheda__club" data-entra>Sable Pines, the desert course</p>
            <h2 class="scheda__titolo" data-entra>
              <span class="scheda__parola">Hole</span>
              <span class="rullo-num rullo-num--grande" data-rullo="7" data-cifre="1"></span>
              <span class="scheda__nome">The Lone Pine</span>
            </h2>
            <dl class="dati" data-entra>
              <div><dt>Par</dt><dd><span class="rullo-num" data-rullo="par" data-cifre="1"></span></dd></div>
              <div><dt>Yards</dt><dd><span class="rullo-num" data-rullo="yards" data-cifre="3"></span></dd></div>
              <div><dt>Handicap</dt><dd><span class="rullo-num" data-rullo="5" data-cifre="1"></span></dd></div>
            </dl>
            <div class="pin" data-entra>
              <span class="pin__nome">To the pin</span>
              <span class="pin__cifre"><span class="rullo-num" data-rullo="pin" data-cifre="3"></span><small>yd</small></span>
              <i class="pin__barra"><i data-pin-barra></i></i>
            </div>
            <blockquote class="consiglio" data-entra>
              <p>“Aim at the lone pine. Anything right of it finds the waste sand.”</p>
              <cite>Dario Reyes, head pro</cite>
            </blockquote>
            <div class="punteggio" data-entra>
              <span class="punteggio__nome">Your score</span>
              <span class="punteggio__cifra">
                <span class="rullo-num rullo-num--grande" data-rullo="score" data-cifre="1"></span>
                <svg class="punteggio__giro" viewBox="0 0 60 60" aria-hidden="true"><path data-giro d="M30 5.5c13.8.2 24.7 11 24.5 24.6S43.4 54.8 29.7 54.5 5.3 43.3 5.5 29.6C5.7 17.4 15 7.6 27 5.8" pathLength="1" /></svg>
              </span>
              <span class="punteggio__esito"><span data-esito>Birdie</span></span>
            </div>
          </aside>
        </div>
      </div>
    </section>

    <section class="apertura apertura--fine">
      <h2 class="titolo titolo--medio">Play it <em>for real.</em></h2>
      <a class="pulsante" href="#"><span>Book a tee time</span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h10M9 4l4 4-4 4" /></svg></a>
    </section>
  </main>

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

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

50 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Golf hole flyover” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

At the top of the page of Sable Pines, a made-up desert golf club, the heading “Hole 7, the Lone Pine.” invites you down. Then the stage stops: on the left the aerial photo of the hole (on top on a phone), on the right the hole card (under it). The photo opens from its middle, a little wider than tall, and the camera settles from a slight zoom; over the photo lie the low desert sun, a soft vignette and a breath of grain. Meanwhile the card comes in line by line and rolls its figures like an odometer, blurred while they run: Hole 7, Par 4, 412 yards, handicap 5, and “To the pin 412”. Then the hole is played: on the tee a white ring opens with a ripple leaving it, and the ball sets off. The flight of the drive draws itself in orange over a dark halo, the ball rises and grows while its shadow runs along the ground on the dashed line, and the camera follows it a little; where it lands an orange ring opens with a ripple and a frosted glass chip rises beside it, counting “Drive 268 yd”. The yards to the pin roll to 144, the thin bar under them shortens and the score reads 1. The approach does the same onto the green, the camera leans toward the cup, the flag rises from the cup, unfurls and waves on its own; the ball rolls across the green along a row of dots and drops into the cup. “Putt 18 ft”, the yards reach 000 with the leading zeros written faint, as on a scoreboard, the score reads 3. At the end the 3 is circled by hand in orange, as on real scorecards, and “Birdie” rises. At the bottom “Play it for real.” and the “Book a tee time” button. Everything follows the scroll, backwards too.

How it works

A still stage and some numbers

The section is 520vh tall times RIDE and a 100lvh sticky stage stays still inside it. A GSAP timeline tied to the scroll (scrub SCRUB) moves numbers, not elements: the opening of the photo, the camera, the flight of each shot, the rings, the chips, the flag, the putt, the circle. On every update a single function rewrites everything from those numbers.

The shot in the photo's units

The SVG over the photo has the image's own viewBox (1024 by 576) and the plate has the same ratio, so the tee, the landings and the cup stay on the right spot of the photo at any size. Each flight is a quadratic curve with its control point straight above the middle of the shot: higher on screen means higher in the air, and the curve's x moves evenly with time, so the shadow on the ground follows it exactly.

The line that draws itself and the ball

The flight has pathLength 1 and draws itself with stroke-dashoffset from 1 to 0, over a wider dark halo that makes it read on grass and on sand. The ground track is dashed and uncovered by a mask drawn the same way. Widths and radii are in real pixels: the script turns them into photo units on every frame, camera included.

The figures on their drums

Every digit is a strip of numbers in a window one figure tall; it moves by -n em with the ROLL curve. Digits always turn forward like a slot (from 4 to 1 they pass 5, 6, 7, 8, 9, 0), the first time with one extra turn; while they run they blur, and the leading zeros are faint as on a scoreboard.

The flag

The cloth is a path redrawn on every frame by the GSAP ticker: its top and bottom edges are two sine waves out of phase, wider toward the tip and drooping a little, with the strength WIND.

Values to change

NameFileDefaultWhat it changes
RIDEscript.js1How much scroll the whole hole takes: 2 is twice as long.
DRIVEscript.js268The yards of the drive, written in its chip (the shots add up to the yards of the hole).
APPROACHscript.js138The yards of the approach onto the green.
PUTTscript.js18The feet of the putt (three feet to a yard).
PARscript.js4The par of the hole: three strokes on a par 4 is a birdie, on a par 3 a par.
ARCscript.js1How high the ball flies: 0 flat, 2 twice as high.
ROLLscript.js'back.out(1.6)'The curve of the rolling figures.
GRAINscript.js0.08How much film grain lies on the photo.
WINDscript.js1How much the flag waves: 0 still.
SCRUBscript.js0.8How many seconds the hole takes to catch up with the scroll.

Try them in the Playground

When to use it

For the page of a hole or of the course of a golf club, of a resort with a golf course, of a tournament or of an app for players: when a real aerial photo is the course and the game is told over it. Swap the photo in the img of the HTML; the tee, the landings and the cup are four points at the top of the script (T, D, G, P) in the photo's units. The colours are in :root.

On phones

The same animations at adapted sizes: the photo on top, measured on width and height, the hole card under it without the club name and the pro's tip; lines, rings and chips keep their real size.

With reduced motion

No movement: the photo is already open and fades in, the camera stays still, the flights, rings and chips fade in without the ball, the figures change without rolling, the flag stays still.

Pitfalls

  • The photo and the SVG need the same ratio: the plate has aspect-ratio 1024/576 like the photo, or object-fit cover would crop the photo and the shot's points would land off the course.
  • Widths in photo units would change with the size (on a phone a 2-unit line is half a pixel): the script recalculates them in real pixels on every frame, divided by the camera zoom too.
  • The camera only moves as far as its zoom allows ((S - 1) / 2 of the photo), or the empty edge would show.
  • The clip-path cuts the shadow too: the plate's shadow is a separate element outside the mask.
  • With GSAP's autoRound on, the stroke-dashoffset from 1 to 0 would be rounded and the line would appear all at once: it is turned off at the top of the script.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Fraunces (font variabile) 5.3.0, Instrument Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 14 KB; the libraries: GSAP + ScrollTrigger 45 KB.

Testing

Tested on 18 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations