Storyline Interaction Lab

Create a Sequential Reveal Interaction in Articulate Storyline with JavaScript

Learn how to create a sequential reveal interaction in Articulate Storyline using custom JavaScript. This step-by-step tutorial covers smooth GSAP animations, professional hover effects, and automatic state management for polished e-learning experiences.

By Nathan Stoker · Published Feb 15, 2026 · Updated Apr 18, 2026 · 12 min read

Download

Watch the video

Create a Sequential Reveal Interaction in Articulate Storyline with JavaScript

Want to guide learners through content one step at a time without overwhelming them? A sequential reveal interaction is the perfect solution. In this tutorial, you'll learn how to create a sequential reveal interaction in Articulate Storyline using custom JavaScript that transitions smoothly between options with sliding animations and professional hover effects.

This interaction pattern works beautifully for step-by-step processes, progressive disclosure scenarios, or any situation where you want learners to focus on one piece of content before moving to the next. By the end of this guide, you'll have a polished, reusable component that you can adapt for your own e-learning projects.

What You'll Build

This interaction features three options that reveal sequentially when clicked. Each option consists of two elements: a background rectangle that slides into view and a clickable thumbnail that fades in on top. When a learner clicks the thumbnail, the current option fades out while the next slides in from the left.

The JavaScript handles several sophisticated behaviors automatically. Smooth GSAP-powered animations control all transitions. A glowing hover effect follows the actual shape of your thumbnails using CSS filters. Mouse position tracking ensures hover states appear instantly, even when elements animate into position under the cursor. The system also resets automatically when revisiting the slide or layer.

Setting Up Your Storyline Elements

Before adding any code, you need to create six objects on your slide or layer. These form three pairs, with each pair containing a background rectangle and a clickable thumbnail.

Creating the Element Pairs

For each of the three options, add a rectangle shape that will serve as the content container. This could display text, images, or any content you want to reveal. Position all three rectangles in the same location on the stage since they'll slide in and out of this shared space.

Next, add a thumbnail element for each option. These can be any shape, including custom graphics with transparency. The hover effect uses CSS drop-shadow, which follows the actual visible pixels rather than the bounding box. This means irregular shapes like stars, circles, or custom icons will glow correctly around their edges.

Capturing the Data Model IDs

Open the published output folder and locate the story_content directory. Find the HTML file for your slide and search for your element names. Each element has a data-model-id attribute that looks like a random string of characters.

You need six IDs total: one for each rectangle and one for each thumbnail. The code expects this structure:

var IDS = {
  option1: { rect: '5aSpZk6XQj4', thumb: '6JyDOAvXZWS' },
  option2: { rect: '6YrWRckW3sM', thumb: '5u1qkU8sE33' },
  option3: { rect: '6jy98zczNqq', thumb: '5nReT6UwVnO' }
};

Replace these example IDs with the actual values from your published output.

Understanding the Animation System

The JavaScript uses GSAP (GreenSock Animation Platform) for smooth, hardware-accelerated animations. Storyline includes GSAP by default, so no additional libraries are needed.

Slide and Fade Transitions

Rectangles animate horizontally using percentage-based transforms. A value of '-101%' positions an element completely off-screen to the left, while '0%' centers it in its original position. This approach works regardless of the element's actual pixel dimensions.

Thumbnails use opacity transitions. They fade from 0 to 1 when appearing and from 1 to 0 when disappearing. The code disables pointer events during transitions to prevent accidental clicks on invisible elements.

The Hover Effect System

Traditional CSS hover effects apply to the element's bounding box. This causes problems with irregular shapes because the glow appears around an invisible rectangle. The solution uses drop-shadow filters instead:

var HOVER = {
  scale: 1.12,
  glowColor: 'rgba(100, 180, 255, 0.8)',
  glowSize: 20,
  transitionSpeed: 0.2
};

The drop-shadow filter traces the actual visible pixels of an element. A star shape glows like a star. A circular thumbnail glows in a circle. This creates a polished, professional appearance that respects your design choices.

Mouse Position Tracking

One subtle but important feature tracks the mouse position globally. When an element animates into view, the code checks whether the cursor is already hovering over it. If so, it applies the hover effect immediately rather than waiting for a mouse movement.

This prevents a common usability issue where learners click, keep their mouse still, and the new element appears without any hover feedback until they move the cursor.

Complete Code

Add this JavaScript to your slide using an Execute JavaScript trigger. Set the trigger to fire when the timeline starts.

(function () {
  'use strict';

  /*** CONFIG ***/
  // Replace these IDs with your actual data-model-id values
  var IDS = {
    option1: { rect: '5aSpZk6XQj4', thumb: '6JyDOAvXZWS' },
    option2: { rect: '6YrWRckW3sM', thumb: '5u1qkU8sE33' },
    option3: { rect: '6jy98zczNqq', thumb: '5nReT6UwVnO' }
  };

  // Animation timing and easing
  var DUR = 0.45;
  var EASE = 'power2.out';
  var DEBUG = true;

  // Hover effect settings - customize the glow appearance
  var HOVER = {
    scale: 1.12,
    glowColor: 'rgba(100, 180, 255, 0.8)',
    glowSize: 20,
    transitionSpeed: 0.2
  };

  // Track mouse position globally for hover-on-reveal
  var mouseX = -9999, mouseY = -9999;
  document.addEventListener('mousemove', function(e) {
    mouseX = e.clientX;
    mouseY = e.clientY;
  }, { passive: true });

  function log(){ if (DEBUG && window.console) console.log.apply(console, ['[ThumbStepper]'].concat([].slice.call(arguments))); }

  /*** Element getters ***/
  function getEl(id, fallbackVarName){
    try{ if (typeof window[fallbackVarName] !== 'undefined' && window[fallbackVarName] && window[fallbackVarName].nodeType === 1) return window[fallbackVarName]; } catch(_){}
    return document.querySelector('[data-model-id="'+id+'"]');
  }

  /*** Check if mouse is over element (with small tolerance) ***/
  function isMouseOver(el, padding) {
    if (!el || mouseX === -9999) return false;
    var p = padding || 5;
    var rect = el.getBoundingClientRect();
    return mouseX >= (rect.left - p) && 
           mouseX <= (rect.right + p) && 
           mouseY >= (rect.top - p) && 
           mouseY <= (rect.bottom + p);
  }

  /*** Fast style setters ***/
  function setSlide(el, x){ 
    if (!el) return; 
    if (typeof gsap !== 'undefined') gsap.set(el, { x: x });
    else el.style.transform = 'translateX(' + x + ')';
  }

  function slideTo(el, x, done){
    if (!el){ if (done) done(); return; }
    if (typeof gsap !== 'undefined'){
      gsap.to(el, { x: x, duration: DUR, ease: EASE, onComplete: done || null });
    } else {
      el.style.transition = 'transform ' + DUR + 's ease';
      el.style.transform = 'translateX(' + x + ')';
      if (done) setTimeout(done, (DUR * 1000) + 30);
    }
  }

  function setOpacity(el, o){ 
    if (!el) return; 
    if (typeof gsap !== 'undefined') gsap.set(el, { opacity: o }); 
    else el.style.opacity = String(o); 
  }

  function fadeTo(el, o, done){
    if (!el){ if (done) done(); return; }
    if (typeof gsap !== 'undefined'){
      gsap.to(el, { opacity: o, duration: DUR, ease: EASE, onComplete: done || null });
    } else {
      el.style.transition = 'opacity ' + DUR + 's ease';
      el.style.opacity = String(o);
      if (done) setTimeout(done, (DUR * 1000) + 30);
    }
  }

  function enable(el, on){ if (el) el.style.pointerEvents = on ? '' : 'none'; }

  function primeForPerf(el, isRect){ 
    if (el) { 
      el.style.willChange = isRect ? 'transform' : 'opacity, transform, filter'; 
      el.style.touchAction = 'manipulation'; 
    } 
  }

  /*** Apply hover state using filter (works on any shape!) ***/
  function applyHover(el) {
    if (!el) return;
    if (typeof gsap !== 'undefined') {
      gsap.to(el, {
        scale: HOVER.scale,
        duration: HOVER.transitionSpeed,
        ease: 'power2.out'
      });
    } else {
      el.style.transform = 'scale(' + HOVER.scale + ')';
    }
    el.style.filter = 'drop-shadow(0 0 ' + HOVER.glowSize + 'px ' + HOVER.glowColor + ')';
  }

  /*** Remove hover state ***/
  function removeHover(el) {
    if (!el) return;
    if (typeof gsap !== 'undefined') {
      gsap.to(el, {
        scale: 1,
        duration: HOVER.transitionSpeed,
        ease: 'power2.out'
      });
    } else {
      el.style.transform = 'scale(1)';
    }
    el.style.filter = '';
  }

  /*** Hover effect setup ***/
  function setupHoverEffects(el) {
    if (!el) return;
    
    el.style.cursor = 'pointer';
    el.style.transition = 'filter ' + HOVER.transitionSpeed + 's ease-out';
    
    if (el.__hoverIn) el.removeEventListener('pointerenter', el.__hoverIn);
    if (el.__hoverOut) el.removeEventListener('pointerleave', el.__hoverOut);
    
    el.__hoverIn = function() {
      if (el.style.pointerEvents === 'none') return;
      applyHover(el);
    };
    
    el.__hoverOut = function() {
      removeHover(el);
    };
    
    el.addEventListener('pointerenter', el.__hoverIn);
    el.addEventListener('pointerleave', el.__hoverOut);
  }
  
  /*** Check hover state after element becomes visible/interactive ***/
  function checkHoverOnReveal(el) {
    if (!el) return;
    
    var checks = 0;
    var maxChecks = 10;
    var applied = false;
    
    function poll() {
      checks++;
      if (applied) return;
      
      if (el.style.pointerEvents !== 'none' && isMouseOver(el)) {
        applied = true;
        applyHover(el);
        
        try {
          el.dispatchEvent(new PointerEvent('pointerenter', {
            bubbles: true,
            clientX: mouseX,
            clientY: mouseY
          }));
        } catch(e) {}
        
        log('Hover applied on reveal, check #' + checks);
        return;
      }
      if (checks < maxChecks) {
        setTimeout(poll, 50);
      }
    }
    
    poll();
  }

  /*** Clear hover state ***/
  function clearHoverState(el) {
    if (!el) return;
    if (typeof gsap !== 'undefined') gsap.set(el, { scale: 1 });
    else el.style.transform = 'scale(1)';
    el.style.filter = '';
  }

  /*** Layer utilities ***/
  function getLayerRoot(el){
    var n = el;
    while (n && n !== document.body){
      if (n.classList && n.classList.contains('slide-layer')) return n;
      n = n.parentNode;
    }
    return document.querySelector('.slide-layer.shown') || null;
  }

  function isLayerShown(layerEl){
    if (!layerEl) return true;
    var ah = layerEl.getAttribute && layerEl.getAttribute('aria-hidden');
    return (ah !== 'true') || layerEl.classList.contains('shown');
  }

  /*** Initial capture ***/
  var els = {
    option1: { rect: null, thumb: null },
    option2: { rect: null, thumb: null },
    option3: { rect: null, thumb: null }
  };

  function capture(){
    els.option1.rect  = getEl(IDS.option1.rect,  'option1rectangle');
    els.option1.thumb = getEl(IDS.option1.thumb, 'option1thumb');
    els.option2.rect  = getEl(IDS.option2.rect,  'option2rectangle');
    els.option2.thumb = getEl(IDS.option2.thumb, 'option2thumb');
    els.option3.rect  = getEl(IDS.option3.rect,  'option3rectangle');
    els.option3.thumb = getEl(IDS.option3.thumb, 'option3thumb');
  }

  /*** Hard reset — only OPTION1 visible ***/
  function initState(){
    setSlide(els.option1.rect, '0%');
    setOpacity(els.option1.thumb, 1);
    enable(els.option1.thumb, true);
    clearHoverState(els.option1.thumb);

    setSlide(els.option2.rect, '-101%');
    setOpacity(els.option2.thumb, 0);
    enable(els.option2.thumb, false);
    clearHoverState(els.option2.thumb);

    setSlide(els.option3.rect, '-101%');
    setOpacity(els.option3.thumb, 0);
    enable(els.option3.thumb, false);
    clearHoverState(els.option3.thumb);
    
    checkHoverOnReveal(els.option1.thumb);
  }

  /*** Wire interactions ***/
  function wire(){
    ['option1','option2','option3'].forEach(function(k){
      var t = els[k].thumb;
      var r = els[k].rect;
      if (!t && !r) return;
      if (t && t.__boundPD){ t.removeEventListener('pointerdown', t.__boundPD); }
      primeForPerf(t, false);
      primeForPerf(r, true);
      setupHoverEffects(t);
    });

    // Option1 → show option2
    if (els.option1.thumb){
      els.option1.thumb.__boundPD = function(){
        enable(els.option1.thumb, false);
        clearHoverState(els.option1.thumb);
        fadeTo(els.option1.thumb, 0, function(){
          slideTo(els.option2.rect, '0%', function(){
            fadeTo(els.option2.thumb, 1, function(){ 
              enable(els.option2.thumb, true);
              checkHoverOnReveal(els.option2.thumb);
            });
          });
        });
      };
      els.option1.thumb.addEventListener('pointerdown', els.option1.thumb.__boundPD);
    }

    // Option2 → show option3
    if (els.option2.thumb){
      els.option2.thumb.__boundPD = function(){
        enable(els.option2.thumb, false);
        clearHoverState(els.option2.thumb);
        fadeTo(els.option2.thumb, 0, function(){
          slideTo(els.option3.rect, '0%', function(){
            fadeTo(els.option3.thumb, 1, function(){ 
              enable(els.option3.thumb, true);
              checkHoverOnReveal(els.option3.thumb);
            });
          });
        });
      };
      els.option2.thumb.addEventListener('pointerdown', els.option2.thumb.__boundPD);
    }

    // Option3 → fade out
    if (els.option3.thumb){
      els.option3.thumb.__boundPD = function(){
        enable(els.option3.thumb, false);
        clearHoverState(els.option3.thumb);
        fadeTo(els.option3.thumb, 0);
      };
      els.option3.thumb.addEventListener('pointerdown', els.option3.thumb.__boundPD);
    }
  }

  /*** Observe for revisits ***/
  function observeLayer(layerRoot){
    if (!layerRoot) return;
    initState();

    var attrObs = new MutationObserver(function(muts){
      for (var i=0;i<muts.length;i++){
        var m = muts[i];
        if (m.type==='attributes' && (m.attributeName==='class' || m.attributeName==='aria-hidden' || m.attributeName==='style')){
          if (isLayerShown(layerRoot)) initState();
        }
      }
    });
    try { attrObs.observe(layerRoot, { attributes:true, attributeFilter:['class','aria-hidden','style'] }); } catch(_){}

    var docObs = new MutationObserver(function(){
      var replaced = false;
      ['option1','option2','option3'].forEach(function(k){
        var curT = document.querySelector('[data-model-id="'+IDS[k].thumb+'"]');
        var curR = document.querySelector('[data-model-id="'+IDS[k].rect+'"]');
        if (curT && curT !== els[k].thumb){ els[k].thumb = curT; replaced = true; }
        if (curR && curR !== els[k].rect ){ els[k].rect  = curR; replaced = true; }
      });
      if (replaced){ wire(); if (isLayerShown(layerRoot)) initState(); }
    });
    try { docObs.observe(document.body, { childList:true, subtree:true }); } catch(_){}
  }

  /*** Bootstrap ***/
  (function boot(waitMs, intervalMs){
    var deadline = Date.now() + (waitMs || 8000), iv = intervalMs || 80;
    (function tick(){
      capture();
      if (els.option1.rect && els.option1.thumb){
        [els.option1.thumb, els.option2.thumb, els.option3.thumb].forEach(function(el){ primeForPerf(el, false); });
        [els.option1.rect, els.option2.rect, els.option3.rect].forEach(function(el){ primeForPerf(el, true); });
        initState();
        wire();
        var layerRoot = getLayerRoot(els.option1.rect || els.option1.thumb);
        observeLayer(layerRoot);
        window.addEventListener('pageshow', function(){ capture(); wire(); if (isLayerShown(layerRoot)) initState(); });
        return;
      }
      if (Date.now() > deadline){ log('Timeout waiting for option1 rect/thumb'); return; }
      setTimeout(tick, iv);
    })();
  })(8000, 80);
})();

Customizing the Interaction

The code includes several configuration options you can adjust without understanding the underlying logic.

Animation Timing

The DUR variable controls how long each animation takes in seconds. The default of 0.45 seconds feels snappy but smooth. Increase this value for a more relaxed pace or decrease it for faster transitions.

The EASE variable accepts any GSAP easing function. The default 'power2.out' starts fast and decelerates smoothly. Try 'power3.out' for more dramatic deceleration or 'elastic.out(1, 0.5)' for a bouncy effect.

Hover Effect Appearance

Customize the hover effect by modifying the HOVER object:

var HOVER = {
  scale: 1.12,                           // How much larger on hover
  glowColor: 'rgba(100, 180, 255, 0.8)', // Glow color with transparency
  glowSize: 20,                          // Glow radius in pixels
  transitionSpeed: 0.2                   // Hover animation duration
};

For a warm glow effect, try 'rgba(255, 180, 100, 0.8)'. For a purple theme, use 'rgba(180, 100, 255, 0.8)'. Adjust the fourth value (0.8) to control transparency.

Adding More Options

To extend the interaction beyond three options, add additional entries to the IDS object and create corresponding click handlers in the wire() function. Follow the existing pattern where each option fades out, slides the next rectangle into view, then fades in the next thumbnail.

Troubleshooting Common Issues

If your interaction isn't working, check these common problems first.

Elements Not Found

The console will log Timeout waiting for option1 rect/thumb if the JavaScript can't find your elements. Double-check that your data-model-id values match exactly. These IDs are case-sensitive and change if you delete and recreate objects.

Animations Not Playing

Ensure GSAP is available by checking that your Storyline project uses the default HTML5 output. Custom player configurations might affect library loading. The code includes CSS fallbacks, but GSAP provides smoother performance.

Hover Effect Not Showing

The drop-shadow filter requires visible pixels to trace. Fully transparent elements won't show any glow. Make sure your thumbnails have actual visual content, not just a hit area.

State Not Resetting

The MutationObserver watches for layer visibility changes. If your elements are on the base slide rather than a layer, the automatic reset might not trigger. Add a timeline trigger to call the JavaScript again when revisiting the slide.

Key Takeaways

Creating a sequential reveal interaction in Articulate Storyline combines careful element setup with JavaScript that manages state, animations, and user feedback. The data-model-id attribute provides reliable element targeting across publishes. GSAP handles smooth animations automatically. CSS drop-shadow filters create shape-aware hover effects that work with any design.

This pattern scales easily to more options and adapts to different visual styles through configuration changes. The automatic reset behavior ensures learners always see the interaction fresh, whether they're visiting for the first time or returning to review.

Ready to try it yourself? Download the example Storyline file from our resources page, or explore our other JavaScript tutorials for Articulate Storyline to discover more ways to enhance your e-learning projects.

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