Skip to content
animorio
IT
All components

Canvas context menu

Menus, Hover, TransitionsGSAP, CSS onlyAdvancedCompressed weight: Demo 14 KBGSAP 28 KBFreeDownload the zip

The right-click menu on the canvas of Tessel, a made-up design tool, on white: it is born exactly at the click point from a 0.96 scale, while a wide shadow gathers under it and settles. The items arrive a few milliseconds apart with their shortcuts drawn as real keys, a blue highlight follows the item under the pointer on a spring, and Arrange opens its submenu to the side with the safe triangle. Press an item: a short flash, the menu closes and the frame on the canvas really moves: forward, to the back, duplicated or deleted.

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>
<!--
  "Canvas context menu" 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>The design canvas context menu born at the click point</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <svg width="0" height="0" style="position:absolute" aria-hidden="true">
    <defs>
      <symbol id="k-cmd" viewBox="0 0 12 12"><path d="M4.2 4.2h3.6v3.6H4.2zM4.2 4.2V3a1.2 1.2 0 1 0-1.2 1.2h1.2zm3.6 0V3A1.2 1.2 0 1 1 9 4.2H7.8zm0 3.6V9A1.2 1.2 0 1 0 9 7.8H7.8zm-3.6 0V9A1.2 1.2 0 1 1 3 7.8h1.2z"/></symbol>
      <symbol id="k-shift" viewBox="0 0 12 12"><path d="M6 2.2 2.2 6.4h2.2v3.2h3.2V6.4h2.2z"/></symbol>
      <symbol id="k-del" viewBox="0 0 12 12"><path d="M4.4 3h5.4a.9.9 0 0 1 .9.9v4.2a.9.9 0 0 1-.9.9H4.4L1.6 6zM5.8 4.8l2.4 2.4m0-2.4L5.8 7.2"/></symbol>
      <symbol id="k-chev" viewBox="0 0 12 12"><path d="M4.6 2.8 7.8 6l-3.2 3.2"/></symbol>
      <symbol id="k-lock" viewBox="0 0 12 12"><rect x="2.6" y="5.2" width="6.8" height="4.6" rx="1.1"/><path d="M4.1 5.2V4a1.9 1.9 0 0 1 3.8 0v1.2"/></symbol>
    </defs>
  </svg>

  <main class="stage">
    <!-- The canvas of Tessel, a made-up design tool: three frames of a landing page. Right-click (or press and hold) a
         frame and its menu is born exactly at the point of the click; Arrange opens its submenu to the side. -->
    <div class="canvas" data-canvas tabindex="0" role="application" aria-label="Tessel canvas. Right-click or press and hold a frame to open its menu. With the keyboard, Shift F10 opens it on the selection.">
      <span class="canvas__grid" aria-hidden="true"></span>
      <span class="canvas__file" aria-hidden="true"><b>Tessel</b><span class="canvas__sep">/</span>Landing v3</span>
      <span class="canvas__zoom" aria-hidden="true">100%</span>

      <div class="layer layer--hero" data-layer="Hero" style="--x:8%;--y:16%;--w:46%;--h:50%">
        <span class="mock mock--nav"><i></i><i></i><i></i></span>
        <span class="mock__title">Ship the<br>launch page</span>
        <span class="mock mock--line"></span>
        <span class="mock mock--line mock--short"></span>
        <span class="mock__cta">Get started</span>
      </div>
      <div class="layer layer--price" data-layer="Pricing card" style="--x:35%;--y:31%;--w:33%;--h:52%">
        <span class="mock__tag">Pro</span>
        <span class="mock__price">$24<small>/mo</small></span>
        <span class="mock mock--line"></span>
        <span class="mock mock--line mock--short"></span>
        <span class="mock mock--line"></span>
        <span class="mock__btn"></span>
      </div>
      <div class="layer layer--quote" data-layer="Testimonial" style="--x:57%;--y:12%;--w:35%;--h:38%">
        <span class="mock__mark">&ldquo;</span>
        <span class="mock mock--line"></span>
        <span class="mock mock--line"></span>
        <span class="mock mock--line mock--short"></span>
        <span class="mock__who"><i></i><b></b></span>
      </div>

      <div class="sel" data-sel aria-hidden="true">
        <span class="sel__name"><svg class="sel__lock"><use href="#k-lock"/></svg><span data-selname>Hero</span></span>
        <span class="sel__size" data-selsize>0 &times; 0</span>
        <i class="sel__h sel__h--tl"></i><i class="sel__h sel__h--tr"></i><i class="sel__h sel__h--bl"></i><i class="sel__h sel__h--br"></i>
      </div>

      <svg class="safe" data-safe aria-hidden="true"><polygon points="0,0 0,0 0,0"/></svg>

      <div class="menu" data-menu role="menu" aria-label="Frame" hidden>
        <span class="menu__far" aria-hidden="true"></span>
        <span class="menu__rest" aria-hidden="true"></span>
        <div class="menu__body">
          <span class="menu__hl" data-hl aria-hidden="true"></span>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="copy" data-needs="layer"><span class="row__label">Copy</span><span class="keys"><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>C</kbd></span></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="paste"><span class="row__label">Paste here</span><span class="keys"><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>V</kbd></span></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="duplicate" data-needs="layer"><span class="row__label">Duplicate</span><span class="keys"><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>D</kbd></span></button>
          <span class="menu__sep" role="separator"></span>
          <button class="row row--sub" type="button" role="menuitem" tabindex="-1" aria-haspopup="menu" aria-expanded="false" data-act="arrange" data-needs="layer"><span class="row__label">Arrange</span><svg class="row__chev"><use href="#k-chev"/></svg></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="lock" data-needs="layer"><span class="row__label" data-locklabel>Lock</span><span class="keys"><kbd><svg><use href="#k-shift"/></svg></kbd><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>L</kbd></span></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="hide" data-needs="layer"><span class="row__label" data-hidelabel>Hide</span><span class="keys"><kbd><svg><use href="#k-shift"/></svg></kbd><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>H</kbd></span></button>
          <span class="menu__sep" role="separator"></span>
          <button class="row row--danger" type="button" role="menuitem" tabindex="-1" data-act="delete" data-needs="layer"><span class="row__label">Delete</span><span class="keys"><kbd><svg><use href="#k-del"/></svg></kbd></span></button>
        </div>
      </div>

      <div class="menu menu--sub" data-sub role="menu" aria-label="Arrange" hidden>
        <span class="menu__far" aria-hidden="true"></span>
        <span class="menu__rest" aria-hidden="true"></span>
        <div class="menu__body">
          <span class="menu__hl" data-hl aria-hidden="true"></span>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="front"><span class="row__label">Bring to front</span><span class="keys"><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>]</kbd></span></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="forward"><span class="row__label">Bring forward</span><span class="keys"><kbd>]</kbd></span></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="backward"><span class="row__label">Send backward</span><span class="keys"><kbd>[</kbd></span></button>
          <button class="row" type="button" role="menuitem" tabindex="-1" data-act="back"><span class="row__label">Send to back</span><span class="keys"><kbd><svg><use href="#k-cmd"/></svg></kbd><kbd>[</kbd></span></button>
        </div>
      </div>

      <div class="note" data-note role="status" aria-live="polite"><span data-notetext></span></div>

      <svg class="hand" data-hand viewBox="0 0 24 24" aria-hidden="true"><path d="M5 2.5l13.2 12.1-5.9.4 3.4 6.4-2.6 1.3-3.3-6.5L5 20.3z"/></svg>
    </div>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.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.

55 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 “Canvas context menu” 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

A warm grey canvas with a thin grid, the file name at the top and three frames of a landing page: the hero «Ship the launch page», the dark card of the Pro plan and a testimonial. Right-click a frame (or press and hold it on a phone, or Shift F10 from the keyboard) and the frame is selected, with the blue outline, the handles, its name and size, and the menu is born at the exact pixel of the click: it grows from 0.96 to 1 with a pixel of overshoot, while a wide low shadow tightens under it and gives way to the resting one. The items come down one after the other 14 milliseconds apart, the shortcut keys arrive a moment later sliding in from the left. A blue highlight follows the item under the pointer on a spring, the word widens a touch on the wdth axis and the Arrange chevron takes a step forward. Rest on Arrange and the submenu slides out to the side, lined up with its row; going to it on the diagonal over Lock and Hide, a faintly drawn safe triangle keeps Arrange chosen. Press an item: the highlight fills with blue, blinks off for a moment, comes back, the keys sink a pixel and the menu closes; then the frame really moves (forward, to the back, duplicated, locked, hidden or deleted) with its neighbours feeling the knock, and a note at the bottom says what happened.

How it works

Born at the click pixel

The menu is measured, flipped if it does not fit to the right or below and kept inside the canvas; its transform-origin though stays the click point, even when the menu had to move, so it always grows from there. The scale goes from 0.96 to 1.004 and back to 1 with two keyframes: a pixel of overshoot on a 214 wide menu.

The shadow that settles

Two shadow layers apart from the menu: a wide low one, as if the menu were still lifted, that tightens and fades; and a resting one, four shadows deep, that arrives a moment later. Together they make the shadow that gathers under the menu as it lands.

The highlight on a spring

The highlight is a single element, moved in a GSAP ticker loop by a real spring on position and height (stiffness and damping are knobs) with the time step capped at 1/30 of a second. Once it rests it stops redrawing.

The safe triangle

From Arrange, the pointer’s point and the two corners of the submenu’s near side make a triangle. As long as the pointer is inside it and moving towards the submenu, Arrange stays chosen; if it stops, after SAFE_WAIT seconds the item under it wins. The triangle is drawn faintly in SVG, and it works on a phone too, where the submenu overlaps the right half of the menu.

One code for two pointers

The menu does not use :hover: the script works out which item is under a point by itself, on the rows’ offsets. The pilot’s drawn pointer and the real one go through the same function; at the first real gesture the pilot stops and starts again after six quiet seconds.

The flash and the action

A short timeline fills the highlight with blue, switches it off for 40 milliseconds, back on, sinks the keys by a pixel and closes the menu. Then the frame changes place in the stack (z-index), is duplicated by a clone that slides out of the original, or is deleted, and the frames it touched settle a little.

Values to change

NameFileDefaultWhat it changes
OPEN_SCALEscript.js0.96The scale the menu is born at, from the click point.
OPEN_TIMEscript.js0.26Seconds for the menu to reach its full size.
STAGGERscript.js0.014Seconds between one item and the next as the menu opens.
SHADOW_TIMEscript.js0.55Seconds for the shadow to gather and settle under the menu.
HL_STIFFNESSscript.js640The spring pulling the highlight to the item under the pointer.
HL_DAMPINGscript.js36Lower, the highlight passes the item and comes back.
SUB_DELAYscript.js0.12Seconds resting on Arrange before the submenu opens.
SAFE_WAITscript.js0.3How long the triangle keeps Arrange once the pointer stops.
SHOW_SAFEscript.jstrueDraw the safe triangle faintly while it works.
HOLD_TIMEscript.js0.45Seconds of pressing on a phone before the menu opens.
PACEscript.js1The pilot’s pauses: higher waits longer between moves.
LOOPscript.jstrueThe pilot plays the story again and again.

Try them in the Playground

When to use it

In design apps, page, slide or whiteboard editors, file managers and any canvas where people right-click an object. It also works as the actions menu of a row or a card, opened where the click was.

On phones

The same animation: the canvas narrows to the full width, the menu and its items get a little shorter, a long press opens the menu and sliding the finger and letting go over an item chooses it. The submenu, with no room to the side, opens under Arrange over the right half of the menu, with the triangle still doing its job.

With reduced motion

Nothing moves or scales: the menu and submenu fade in in place, the highlight jumps to the item without a spring, the frames change place without settling and the pilot’s pointer is hidden.

Pitfalls

  • On a phone the submenu fits neither right nor left: placed over the menu at Arrange’s height it covered the row and the triangle had no side to start from; it now opens under Arrange over the right half, and the triangle takes the submenu side nearest the pointer.
  • On a Mac the right button is released over the menu that was just born: without ignoring the right button’s pointerup, the item under the pointer was chosen at once.
  • On Android a long press also fires the browser’s contextmenu: if it comes before our timer, it opens the menu and our timer is cancelled, otherwise the menu opened twice.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 11 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 components