Motion & Games

Build a Clickable Dial Interaction in Articulate Storyline with JavaScript and GSAP

Learn how to build a clickable dial interaction in Articulate Storyline using JavaScript and GSAP. Each click rotates a needle, transitions colors, swaps images, and updates text, all in one synchronized animation powered by a single trigger.

By Nathan Stoker · Published Oct 25, 2026 · 7 min read

Build a Clickable Dial Interaction in Articulate Storyline with JavaScript and GSAP

Want to give your learners an interactive dial they can click through, with synchronized color changes, image swaps, and dynamic text? This clickable dial interaction in Articulate Storyline lets you build exactly that using JavaScript and GSAP. Each click advances a dial needle, transitions a background color, swaps out a visual, and updates a text variable, all in one fluid motion.

This is a great way to walk learners through escalating stages of a concept (think severity levels, risk scales, or progress indicators) without relying on multiple slides or clunky built-in triggers. Let's walk through how it works and how to set it up in your own Storyline project.

How the Clickable Dial Interaction in Articulate Storyline Works

At a high level, the interaction is built around a single click event on a dial graphic. Each click does four things simultaneously:

  • Rotates the dial needle to the next position

  • Transitions a shape's fill color to match the new stage

  • Swaps one image for another (with an instant swap to stay in sync)

  • Updates a Storyline text variable with new content

When the dial reaches its final position, a subtle pulse animation stops to signal completion. One more click resets everything back to the starting state.

The entire interaction is powered by a single JavaScript trigger using GSAP (GreenSock Animation Platform) for smooth, hardware-accelerated animations.

What You'll Need in Storyline

Before pasting the code, you'll need to set up a few things on your slide.

Slide Elements

You need four types of elements on your slide:

The dial. This is a graphic (PNG or SVG) of a dial with a needle. The JavaScript rotates the inner SVG, so the needle graphic should point upward at its default position. Take note of its data-model-id.

A color shape. This is any Storyline shape with an SVG fill that will transition between colors. A simple circle or rounded rectangle works well. Take note of its data-model-id.

Stage images (ovals). These are the visuals that swap at each dial position. Create one image per stage and stack them in the same position on the slide. Each one needs its own data-model-id. In the example code, there are four.

Text variable display. Create a Storyline text variable (the example uses dial_text) and place a reference on your slide to display it. The JavaScript updates this variable at each stage.

Storyline Variables

Create two variables in your Storyline file:

  • dial_number (Number, default 0): tracks the current dial position

  • dial_text (Text, default empty): holds the description for the current stage

Finding Your data-model-id Values

Every element in Storyline gets a unique data-model-id attribute in the published output. To find yours:

  1. Preview your project in a browser

  2. Right-click the element and choose Inspect

  3. Look for the data-model-id attribute on the element's container div

  4. Copy that value into the configuration section of the code

This is how the JavaScript locates and controls each element. For a deeper dive into how Storyline generates these IDs, check out the Articulate community forums.

The JavaScript Trigger Setup

In Storyline, add a single Execute JavaScript trigger:

  • When: Timeline starts (or a specific cue point if you prefer)

  • Action: Execute JavaScript

  • Script: Paste the complete code below

The code is wrapped in an IIFE (Immediately Invoked Function Expression), which is the standard pattern for Storyline JavaScript. This keeps all variables scoped to the trigger and prevents conflicts with other scripts in your project.

Complete Code

Below is the full JavaScript for the clickable dial interaction. The configuration block at the top is where you'll plug in your own data-model-id values, colors, text content, and animation settings.

(function () {
  // ── CONFIGURATION ────────────────────────────────────────────────────
  var DIAL_ID = '6UrNgVAZckW';
  var COLOR_ID = '5xgdXuhGFVq';
  var OVAL_IDS = ['62P7fgoxowh', '5lal57fUuJ1', '5yAI1MTnHTl', '6kfeN7wPoa3'];

  var COLORS = ['#5549b9', '#378985', '#89a761', '#F5961D'];
  var TEXTS = [
    'This little germ is just hanging out, hitching a ride through the monster\'s gut. No toxins, no trouble -- yet. But don\'t be fooled; it\'s quietly spreading to every surface it touches.',
    'The first toxin kicks in, gnawing at the gut walls and stirring up a nasty ooze. The monster\'s belly rumbles and churns as the infection starts to take hold.',
    'Now the real damage begins. A more vicious toxin rips through the gut lining, leaving raw, inflamed tissue behind. The monster doubles over, growling in pain.',
    'Full-blown infestation. Every toxin is firing at once, shredding defenses from the inside out. The monster is burning up, barely standing, its insides a war zone of unchecked destruction.'
  ];

  var SL_NUMBER_VAR = 'dial_number';
  var SL_TEXT_VAR = 'dial_text';

  var START_ANGLE = -65;
  var MAX_ANGLE = 45;
  var STEP = 45;

  var PULSE_SCALE = 1.05;
  var PULSE_DURATION = 0.25;
  var PULSE_REPEAT_DELAY = 0.15;

  var CLICK_DURATION = 0.35;
  var RESET_DURATION = 0.5;
  var OVAL_POLL_INTERVAL = 50;
  var OVAL_POLL_MAX = 100;

  // ── SETUP ────────────────────────────────────────────────────────────
  var dialOuter = document.querySelector('[data-model-id="' + DIAL_ID + '"]');
  if (!dialOuter) return;
  var dial = dialOuter.querySelector('svg') || dialOuter;

  var colorEl = document.querySelector('[data-model-id="' + COLOR_ID + '"]');
  var colorPath = colorEl ? colorEl.querySelector('svg path') : null;

  var ovals = OVAL_IDS.map(function () { return null; });
  var ovalsReady = false;

  var colorIndex = 0;
  var player = GetPlayer();
  var currentAngle = START_ANGLE;
  var resetting = false;

  gsap.set(dial, { rotation: currentAngle, transformOrigin: '50% 50%' });
  player.SetVar(SL_NUMBER_VAR, 0);
  player.SetVar(SL_TEXT_VAR, TEXTS[0]);
  if (colorPath) colorPath.setAttribute('fill', COLORS[0]);

  // ── PULSE ────────────────────────────────────────────────────────────
  var pulseTween = gsap.to(dialOuter, {
    scale: PULSE_SCALE,
    duration: PULSE_DURATION,
    ease: 'power2.inOut',
    yoyo: true,
    repeat: -1,
    repeatDelay: PULSE_REPEAT_DELAY,
    transformOrigin: '50% 50%'
  });

  function stopPulse() {
    pulseTween.kill();
    gsap.set(dialOuter, { scale: 1, transformOrigin: '50% 50%' });
  }

  // ── OVAL POLLING ─────────────────────────────────────────────────────
  var pollCount = 0;
  var pollTimer = setInterval(function () {
    pollCount++;
    var allFound = true;
    OVAL_IDS.forEach(function (id, i) {
      if (ovals[i]) return;
      var el = document.querySelector('[data-model-id="' + id + '"]');
      if (el) {
        ovals[i] = el;
      } else {
        allFound = false;
      }
    });

    if (allFound) {
      clearInterval(pollTimer);
      ovalsReady = true;
      ovals.forEach(function (oval) {
        if (oval) gsap.set(oval, { autoAlpha: 0 });
      });
      if (ovals[0]) gsap.set(ovals[0], { autoAlpha: 1 });
    }

    if (pollCount > OVAL_POLL_MAX) {
      clearInterval(pollTimer);
    }
  }, OVAL_POLL_INTERVAL);

  // ── CLICK HANDLER ────────────────────────────────────────────────────
  dialOuter.style.cursor = 'pointer';
  dialOuter.addEventListener('click', function () {
    if (resetting) return;

    if (currentAngle >= MAX_ANGLE) {
      resetting = true;
      var prevColorIndex = colorIndex;
      currentAngle = START_ANGLE;
      colorIndex = 0;
      player.SetVar(SL_NUMBER_VAR, 0);
      player.SetVar(SL_TEXT_VAR, TEXTS[0]);

      // -- swap ovals instantly, then animate everything together
      if (ovalsReady) {
        if (ovals[prevColorIndex]) gsap.set(ovals[prevColorIndex], { autoAlpha: 0 });
        if (ovals[0]) gsap.set(ovals[0], { autoAlpha: 1 });
      }
      if (colorPath) gsap.set(colorPath, { attr: { fill: COLORS[0] } });

      gsap.to(dial, {
        rotation: currentAngle,
        duration: RESET_DURATION,
        ease: 'power2.inOut',
        transformOrigin: '50% 50%',
        onComplete: function () { resetting = false; }
      });
      return;
    }

    var prevColorIndex = colorIndex;
    currentAngle += STEP;
    colorIndex = Math.min(colorIndex + 1, COLORS.length - 1);
    var count = player.GetVar(SL_NUMBER_VAR) + 1;
    player.SetVar(SL_NUMBER_VAR, count);
    player.SetVar(SL_TEXT_VAR, TEXTS[colorIndex]);

    if (colorIndex === COLORS.length - 1) {
      stopPulse();
    }

    // -- swap ovals instantly, then animate dial and color together
    if (ovalsReady) {
      if (ovals[prevColorIndex]) gsap.set(ovals[prevColorIndex], { autoAlpha: 0 });
      if (ovals[colorIndex]) gsap.set(ovals[colorIndex], { autoAlpha: 1 });
    }

    gsap.to(dial, {
      rotation: currentAngle,
      duration: CLICK_DURATION,
      ease: 'power2.out',
      transformOrigin: '50% 50%'
    });

    if (colorPath) {
      gsap.to(colorPath, {
        attr: { fill: COLORS[colorIndex] },
        duration: CLICK_DURATION,
        ease: 'power2.out'
      });
    }
  });
})();

Customizing the Interaction

The configuration block at the top of the code is designed to make customization easy, even if you're not a JavaScript developer.

Changing the Content

Replace the COLORS array with your own hex color values. Each entry corresponds to one dial position. The TEXTS array works the same way: one text string per position, displayed through the Storyline variable.

You can have as many or as few stages as you want. Just make sure your COLORS, TEXTS, and OVAL_IDS arrays all have the same number of entries.

Adjusting the Dial Rotation

Three values control how the needle moves:

  • START_ANGLE: where the needle begins (in degrees; -65 points it to the left)

  • MAX_ANGLE: where the needle ends (45 points it to the right)

  • STEP: how many degrees the needle moves per click

To calculate your step value, divide the total arc by the number of clicks. For example, if your arc goes from -65 to 45 (110 degrees total) and you have 3 clicks, your step is approximately 37.

Tweaking Animation Speed

CLICK_DURATION controls how fast each advance animates (in seconds). RESET_DURATION controls the speed of the reset animation when the learner clicks past the final position. Both default to snappy values that feel responsive without being jarring.

How the Key Techniques Work

A few patterns in this code are worth understanding, even if you plan to copy and paste the whole thing.

Element Polling

Storyline doesn't guarantee that all elements are in the DOM when a JavaScript trigger fires. The polling pattern uses setInterval to check for each oval element every 50 milliseconds, up to 100 attempts. Once all elements are found, the interval clears and the interaction becomes fully functional.

This is a common and reliable pattern for any Storyline interaction that targets multiple elements.

Instant Image Swaps with gsap.set

Early versions of this interaction used animated fades for the image transitions. The problem was that even with GSAP timelines, the fade animations would lag slightly behind the dial rotation and color change, creating a visible desync.

The solution was to use gsap.set() for the image swaps instead. gsap.set() applies changes instantly on the current frame with zero animation, which guarantees the image swap happens at exactly the same moment as the dial click. The dial rotation and color change still animate smoothly; only the images swap instantly.

Pulse Animation

The dial uses a GSAP yoyo tween to create a subtle breathing pulse, signaling to the learner that it's clickable. When the dial reaches its final position, stopPulse() kills the tween and resets the scale. This is a clean, reliable pattern for "pulse until complete" interactions in Storyline.

Wrapping Up

This clickable dial interaction gives you a polished, multi-layered experience from a single JavaScript trigger. The configuration-first structure means you can adapt it to any topic by swapping out IDs, colors, and text content without touching the core logic.

Nathan Stoker

I build custom eLearning in Storyline, Rise and JavaScript, and I make the free tools and templates on this site. Need an interaction like this in your course? Let's talk.

Work with me · Browse templates

Related posts