How to Create a Custom Path Slider in Articulate Storyline
Ever wanted a slider that curves, zigzags, or follows a custom path instead of just moving left to right? In this tutorial, I'll walk you through creating a draggable handle that follows any SVG path you draw in Articulate Storyline—complete with snap points that trigger different content states.
By Nathan Stoker · Published Jan 11, 2026 · Updated Nov 8, 2026 · 9 min read

Make your e-learning interactions stand out with sliders that follow any shape you can imagine
Ever wanted a slider that curves, zigzags, or follows a custom path instead of just moving left to right? In Articulate Storyline, the built-in slider is limited to straight horizontal or vertical movement. But with a little JavaScript magic, you can create sliders that follow any SVG path you draw.
In this tutorial, I'll walk you through creating a slider that lets users drag a handle along a custom curved path—complete with snap points that trigger different content states.
Check out the demo and download the file to follow along.
What We're Building
Imagine a timeline that curves across the screen, or a journey map where users drag through different stops. Our custom path slider lets you:
Draw any path shape you want
Place snap points anywhere along the path
Trigger Storyline variables when users reach each point
Create smooth, responsive dragging on both desktop and mobile
Prerequisites
Before diving in, you should be comfortable with:
Creating shapes and paths in Storyline
Adding JavaScript triggers
Working with Storyline variables
Basic understanding of what SVG paths are (don't worry, you don't need to code them by hand)
Step 1: Set Up Your Storyline Slide
First, let's create the visual elements we need.
Create Your Path
Draw a freeform shape or use the line tool to create your desired path
This will be converted to an SVG path when Storyline publishes
Make sure the path is clearly visible—you can style it however you like
Pro tip: Keep your path relatively simple for your first attempt. A gentle curve works great for learning.
Create Your Handle
Add a shape or image that will serve as the draggable handle
Size it appropriately (around 40-60 pixels works well for touch targets)
Position it somewhere on your slide—the JavaScript will move it to the path
Create Your Snap Point Markers
Add shapes or images at each location where you want the slider to "snap"
These can be visible icons, invisible hotspots, or styled markers
For this tutorial, we'll use 6 snap points
Note the Data Model IDs
This is the crucial step! Each element in Storyline has a unique data-model-id that JavaScript uses to find it.
Publish your project (even a test publish works)
Open the published
story.htmlin a browserRight-click each element and choose "Inspect"
Find the
data-model-idattribute in the HTMLWrite down the IDs for:
Your handle
Your path
Each snap point marker (in order)
Step 2: Create a Storyline Variable
Open the Variables panel
Create a new Number variable called
sliderStepSet the initial value to
0
This variable will update whenever the user drags to a snap point, letting you trigger layers, states, or other actions.
Step 3: Add the JavaScript
Create a new trigger:
Action: Execute JavaScript
When: Timeline starts
Object: This slide
Now paste in the JavaScript code. Here's a breakdown of what you need to customize:
(function () {
// ========== CUSTOMIZE THESE VALUES ==========
// Your handle's data-model-id
const HANDLE_ID = "5WklamGT4gm";
// Your path's data-model-id
const PATH_ID = "6ieYGPIkp0d";
// Your snap point data-model-ids (in order)
const GROUP_IDS = [
"62GAloJy2Ro", // Snap point 0
"6YWQOWopLDi", // Snap point 1
"6CZJLZzE39k", // Snap point 2
"5jzInQ8Oh4G", // Snap point 3
"66q3oJlDIJ0", // Snap point 4
"6LFjxVFqj4u" // Snap point 5
];
// How close (in pixels) the user needs to drag to trigger a snap
const SNAP_THRESHOLD = 100;
// Which snap point to start on (0 = first)
const INITIAL_STEP_INDEX = 0;
// Set to false if you want free dragging without snapping
const ENABLE_STEPS = true;
// ========== END CUSTOMIZATION ==========
Replace the ID values with the ones you noted from your published output.
Step 4: Understanding the Code
Let's break down what the script does so you can troubleshoot and customize.
Finding Elements
The script locates your Storyline elements using their data-model-ids:
const handle = document.querySelector(`[data-model-id="${HANDLE_ID}"]`);
const pathContainer = document.querySelector(`[data-model-id="${PATH_ID}"]`);
Calculating Positions
SVG paths and screen coordinates use different measurement systems. The code converts between them:
const svgRect = svg.getBoundingClientRect();
const viewBox = svg.viewBox.baseVal;
const scaleX = viewBox.width / svgRect.width;
const scaleY = viewBox.height / svgRect.height;
Handling Drag Events
The script listens for mouse and touch events:
handle.addEventListener("mousedown", startDrag);
document.addEventListener("mousemove", onDrag);
document.addEventListener("mouseup", stopDrag);
// Touch support for mobile
handle.addEventListener("touchstart", startDrag);
document.addEventListener("touchmove", onDrag);
document.addEventListener("touchend", stopDrag);
Snapping to Points
When the user drags near a snap point, the handle jumps to it:
const snapIndex = getClosestSnapPoint(x, y);
if (snapIndex !== -1) {
// Snap to this point and update Storyline
GetPlayer().SetVar("sliderStep", snapIndex);
}
Communicating with Storyline
The magic connection happens through GetPlayer():
GetPlayer().SetVar("sliderStep", snapIndex);
This updates your Storyline variable, which you can use in triggers!
Step 5: Create Your Interactions
Now use the sliderStep variable to drive your content:
Show/Hide Layers
Create a trigger:
Action: Show layer
Layer: [Your content layer]
When: Variable changes
Variable: sliderStep
Condition: sliderStep equals [0, 1, 2, etc.]
Change States
Action: Change state of
Object: [Your object]
To state: [State name]
When: Variable changes
Variable: sliderStep
Play Audio or Animation
You can trigger any Storyline action based on the slider position!
Troubleshooting Common Issues
Handle doesn't appear on the path
Double-check your
HANDLE_IDandPATH_IDvaluesMake sure you're using the data-model-id from the published output
Try republishing—IDs can change between publishes
Snapping doesn't work
Verify your
GROUP_IDSarray has the correct IDsIncrease
SNAP_THRESHOLDif the snap points seem too "tight"Check that your marker elements are actually positioned near the path
Dragging feels laggy
The
DEBOUNCE_MSvalue (default 16) controls update frequencyThe
SAMPLE_COUNTvalue (default 100) affects path precision vs. performance
Handle jumps to wrong position
Check that your snap point IDs are in the correct order
Verify the path element contains an actual
<path>tag (not just a group)
Touch doesn't work on mobile
Make sure the handle has sufficient size (at least 44x44 pixels for accessibility)
Test in actual mobile devices, not just browser emulation
Advanced Customizations
Disable Snapping for Free Movement
const ENABLE_STEPS = false;
Start at a Different Position
const INITIAL_STEP_INDEX = 2; // Start at the third snap point
Enable Debug Logging
const DEBUG = true; // See detailed console output
Create a Progress Bar Effect
Instead of discrete snap points, you could read the continuous progress value and use it to fill a shape or update a progress indicator.
The Complete Code
Here's the full JavaScript you need. Copy this into your Execute JavaScript trigger, then customize the ID values at the top:
(function () {
const HANDLE_ID = "YOUR_HANDLE_ID";
const PATH_ID = "YOUR_PATH_ID";
const GROUP_IDS = [
"SNAP_POINT_1_ID",
"SNAP_POINT_2_ID",
"SNAP_POINT_3_ID",
"SNAP_POINT_4_ID",
"SNAP_POINT_5_ID",
"SNAP_POINT_6_ID"
];
const SNAP_THRESHOLD = 100;
const INITIAL_STEP_INDEX = 0;
const ENABLE_STEPS = true;
const DEBOUNCE_MS = 16;
const SAMPLE_COUNT = 100;
const DEBUG = false;
function log(...args) {
if (DEBUG) console.log(...args);
}
function getSnapPoints(pathElement) {
const snapPoints = [];
const svg = pathElement.closest("svg");
const svgRect = svg.getBoundingClientRect();
const viewBox = svg.viewBox.baseVal;
const scaleX = viewBox.width / svgRect.width;
const scaleY = viewBox.height / svgRect.height;
for (let i = 0; i < GROUP_IDS.length; i++) {
const el = document.querySelector(`[data-model-id="${GROUP_IDS[i]}"]`);
if (!el) {
log(`Group ${i} (${GROUP_IDS[i]}) not found`);
return null;
}
const rect = el.getBoundingClientRect();
const centerScreenX = rect.left + rect.width / 2;
const centerScreenY = rect.top + rect.height / 2;
const svgX = (centerScreenX - svgRect.left) * scaleX;
const svgY = (centerScreenY - svgRect.top) * scaleY;
snapPoints.push({ x: svgX, y: svgY });
log(`Group ${i} SVG (X, Y):`, svgX.toFixed(2), svgY.toFixed(2));
}
return snapPoints;
}
function initializePathSlider() {
const handle = document.querySelector(`[data-model-id="${HANDLE_ID}"]`);
const pathContainer = document.querySelector(`[data-model-id="${PATH_ID}"]`);
if (!handle || !pathContainer) {
log("Handle or path container not found, retrying...");
return setTimeout(initializePathSlider, 100);
}
const pathElement = pathContainer.querySelector("path");
if (!pathElement) {
log("Path element not found, retrying...");
return setTimeout(initializePathSlider, 100);
}
const snapPoints = getSnapPoints(pathElement);
if (!snapPoints || snapPoints.length === 0) {
log("No snap points found, retrying...");
return setTimeout(initializePathSlider, 100);
}
const pathLength = pathElement.getTotalLength();
let currentProgress = 0;
let isDragging = false;
let lastSnapIndex = -1;
let lastUpdate = 0;
let lastPosition = null;
const cachedPoints = [];
for (let i = 0; i <= SAMPLE_COUNT; i++) {
const len = (i / SAMPLE_COUNT) * pathLength;
cachedPoints.push(pathElement.getPointAtLength(len));
}
function getMouseXY(e) {
const t = e.touches?.[0] || e;
return { x: t.clientX, y: t.clientY };
}
function getLengthAtXY(xy) {
let minDist = Infinity;
let bestLength = 0;
for (let i = 0; i <= SAMPLE_COUNT; i++) {
const pt = cachedPoints[i];
const dist = Math.hypot(pt.x - xy.x, pt.y - xy.y);
if (dist < minDist) {
minDist = dist;
bestLength = (i / SAMPLE_COUNT) * pathLength;
}
}
return bestLength;
}
const minLength = getLengthAtXY(snapPoints[0]);
const maxLength = getLengthAtXY(snapPoints[snapPoints.length - 1]);
function getClosestSnapPoint(clientX, clientY) {
const svg = pathElement.closest("svg");
const svgRect = svg.getBoundingClientRect();
const viewBox = svg.viewBox.baseVal;
const scaleX = viewBox.width / svgRect.width;
const scaleY = viewBox.height / svgRect.height;
const svgX = (clientX - svgRect.left) * scaleX;
const svgY = (clientY - svgRect.top) * scaleY;
let minDist = Infinity;
let closestIndex = -1;
for (let i = 0; i < snapPoints.length; i++) {
const pt = snapPoints[i];
const dx = pt.x - svgX;
const dy = pt.y - svgY;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestIndex = i;
}
}
return minDist <= SNAP_THRESHOLD ? closestIndex : -1;
}
function getParentTransformOffset() {
const parent = handle.parentElement;
let offsetX = 0, offsetY = 0;
const computedStyle = window.getComputedStyle(parent);
const transform = computedStyle.transform;
if (transform && transform !== "none") {
const matrix = new DOMMatrix(transform);
offsetX += matrix.e;
offsetY += matrix.f;
}
return { x: offsetX, y: offsetY };
}
function positionHandleAtProgress(progress, snapIndex = -1) {
const now = Date.now();
if (now - lastUpdate < DEBOUNCE_MS) return progress;
lastUpdate = now;
const svg = pathElement.closest("svg");
const svgRect = svg.getBoundingClientRect();
const viewBox = svg.viewBox.baseVal;
const scaleX = svgRect.width / viewBox.width;
const scaleY = svgRect.height / viewBox.height;
let pt;
if (snapIndex >= 0 && snapIndex < snapPoints.length) {
pt = snapPoints[snapIndex];
} else {
const clampedLength = minLength + progress * (maxLength - minLength);
const index = Math.round((clampedLength / pathLength) * SAMPLE_COUNT);
pt = cachedPoints[Math.min(index, SAMPLE_COUNT)];
let minDist = Infinity;
let bestPt = pt;
for (let i = Math.max(0, index - 5); i <= Math.min(SAMPLE_COUNT, index + 5); i++) {
const candidatePt = cachedPoints[i];
const dist = Math.hypot(candidatePt.x - pt.x, candidatePt.y - pt.y);
if (dist < minDist) {
minDist = dist;
bestPt = candidatePt;
}
}
pt = bestPt;
}
const screenX = svgRect.left + pt.x * scaleX;
const screenY = svgRect.top + pt.y * scaleY;
const handleRect = handle.getBoundingClientRect();
const parentRect = handle.parentElement?.getBoundingClientRect() || { left: 0, top: 0 };
const parentTransform = getParentTransformOffset();
const w = handleRect.width;
const h = handleRect.height;
const finalX = screenX - parentRect.left - w / 2 - parentTransform.x;
const finalY = screenY - parentRect.top - h / 2 - parentTransform.y;
if (lastPosition && Math.abs(finalX - lastPosition.x) < 0.1 && Math.abs(finalY - lastPosition.y) < 0.1) {
return progress;
}
lastPosition = { x: finalX, y: finalY };
handle.style.position = "absolute";
handle.style.margin = "0";
handle.style.padding = "0";
handle.style.left = `${finalX.toFixed(3)}px`;
handle.style.top = `${finalY.toFixed(3)}px`;
handle.style.transform = "none";
handle.style.transformOrigin = "center center";
log("Positioning for:", snapIndex >= 0 ? `Snap ${snapIndex}` : `Progress ${progress.toFixed(3)}`);
return progress;
}
function findBestProgressForSnap(index) {
const target = snapPoints[index];
let bestProgress = 0;
let minDist = Infinity;
for (let i = 0; i <= SAMPLE_COUNT; i++) {
const pt = cachedPoints[i];
const dist = Math.hypot(pt.x - target.x, pt.y - target.y);
if (dist < minDist) {
minDist = dist;
bestProgress = (i / SAMPLE_COUNT);
}
}
return bestProgress;
}
function moveToInitialStep(index) {
if (index < 0 || index >= snapPoints.length) return;
currentProgress = positionHandleAtProgress(findBestProgressForSnap(index), index);
if (typeof GetPlayer === "function") {
GetPlayer().SetVar("sliderStep", index);
log("Sent to Storyline: sliderStep =", index);
}
lastSnapIndex = index;
}
function onDrag(e) {
if (!isDragging) return;
e.stopPropagation();
const { x, y } = getMouseXY(e);
const snapIndex = ENABLE_STEPS ? getClosestSnapPoint(x, y) : -1;
if (snapIndex !== -1 && snapIndex !== lastSnapIndex) {
currentProgress = positionHandleAtProgress(findBestProgressForSnap(snapIndex), snapIndex);
if (typeof GetPlayer === "function") {
GetPlayer().SetVar("sliderStep", snapIndex);
log("Sent to Storyline: sliderStep =", snapIndex);
}
lastSnapIndex = snapIndex;
} else if (snapIndex === -1) {
const svg = pathElement.closest("svg");
const svgRect = svg.getBoundingClientRect();
const viewBox = svg.viewBox.baseVal;
const scaleX = viewBox.width / svgRect.width;
const scaleY = viewBox.height / svgRect.height;
const svgX = (x - svgRect.left) * scaleX;
const svgY = (y - svgRect.top) * scaleY;
const bestLength = getLengthAtXY({ x: svgX, y: svgY });
const bestProgress = Math.max(0, Math.min(1, (bestLength - minLength) / (maxLength - minLength)));
currentProgress = positionHandleAtProgress(bestProgress);
lastSnapIndex = -1;
}
e.preventDefault();
}
function startDrag(e) {
isDragging = true;
handle.style.cursor = "grabbing";
e.stopPropagation();
e.preventDefault();
}
function stopDrag(e) {
isDragging = false;
handle.style.cursor = "grab";
e.stopPropagation();
}
handle.style.position = "absolute";
handle.style.margin = "0";
handle.style.padding = "0";
handle.style.transform = "none";
handle.style.transformOrigin = "center center";
handle.style.cursor = "grab";
if (handle.tagName.toLowerCase() === "img") {
handle.style.objectFit = "none";
handle.style.objectPosition = "center";
}
moveToInitialStep(INITIAL_STEP_INDEX);
handle.addEventListener("mousedown", startDrag, { capture: true, passive: false });
document.addEventListener("mousemove", onDrag, { capture: true, passive: false });
document.addEventListener("mouseup", stopDrag, { capture: true, passive: false });
handle.addEventListener("touchstart", startDrag, { capture: true, passive: false });
document.addEventListener("touchmove", onDrag, { capture: true, passive: false });
document.addEventListener("touchend", stopDrag, { capture: true, passive: false });
log("Path slider initialized successfully!");
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializePathSlider);
} else {
initializePathSlider();
}
})();
Wrapping Up
Custom path sliders open up a world of creative possibilities in Storyline. Instead of being limited to straight-line interactions, you can now create:
Winding journey maps
Circular progress indicators
Timeline curves
Game-like navigation paths
Interactive infographics
The technique combines Storyline's visual design capabilities with JavaScript's flexibility, giving you the best of both worlds.
Have questions or want to share what you've built? Drop a comment below or reach out—I'd love to see your creative implementations!
Happy building!
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.