Storyline 360: Advanced JavaScript API
Article Last Updated
This article applies to:
Attention, JavaScript enthusiasts! Get ready to unlock powerful interactivity using the advanced JavaScript API feature in Storyline 360. Gain precise control over object properties, trigger custom animations, and create advanced effects like parallax. Read on to learn more.
- Use the Advanced JavaScript API
- Explore JavaScript Code Snippets
- Test a Sample Interaction
- Make Interactions Accessible
- Understand Compatibility
Use the Advanced JavaScript API
When it comes to creating powerful interactions using the advanced JavaScript API, you’ve got options. You can modify object properties, build custom animations, apply code snippets, and more. Explore the possibilities below.
Find the Object ID
To get started, you'll first need to get the object’s ID. Find that information using any of the following methods:
- Right-click the object and select the copy icon. The object ID that isn’t in the parenthesis will be copied to your clipboard.
- In the JavaScript editor, choose your object from the Object reference drop-down arrow, then click Add. The object ID is referenced in the
object()
function.
Define Object Properties
Once you have the object ID, you can reference it to define any of these object properties:
- Position:
x
,y
(horizontal/vertical location) - Scale:
scaleX
,scaleY
,scale
(0–100%) - Rotation:
rotation
(0–360°) - Opacity:
opacity
(0–100%) - Depth Order:
depth
- Size:
width
,height
(read-only) - State:
state
(set by name)
Note: You must use dot syntax to define the position, rotation, and scale object properties. For example:
|
Adjust Core Functions
You can use any of the following core functions:
Mouse Cursor
- Cursor location:
pointerX()
,pointerY()
- Hide the cursor:
hidePointer()
- Show the cursor:
showPointer()
Slide Dimensions
slideWidth()
slideHeight()
Variables (previously GetVar and SetVar)
- Retrieve a variable's value:
getVar('name')
- Set a variable's value:
setVar('name', value)
Updates
- Run a function continuously at 60fps:
update(callback)
|
Explore JavaScript Code Snippets
The following common JavaScript code snippets can also be applied to an object’s ID.
Rotate Object Based on a Variable
|
Follow the Cursor (Mouse or Touch)
|
Point at the Cursor
|
Parallax Motion
|
Move To
|
Animation To make animations seekable on the timeline, wrap them in the
|
Cascading Style Sheets (CSS) Access
|
Test a Sample Interaction
Want to see what’s possible with the advanced JavaScript API? Check out this example. You can explore the code in the project file by clicking the download link in the upper-right corner of the interaction.
Make Interactions Accessible
Follow these tips to make your interactions more accessible:
- Use interactivity strategically. Avoid using animations and effects purely for decoration. They should have a clear purpose, such as guiding learners through a process or bringing focus to a specific detail.
- Consider timing. Keep the duration of your animation and effects to less than five seconds. Interactivity that starts automatically and lasts for more than five seconds must have a way for learners to pause, stop, or hide the interaction to conform to accessibility standards. (2.2.2 Pause, Stop, Hide)
- Give learners control. Provide an option for turning animations and effects off. For example, you could use a true/false variable to track whether a learner wants to see interactivity. Then, depending on the learner's choice, a layer with interactivity or a different layer without interactivity would appear. (2.3.3 Animation from Interactions)
- Meet the minimum target size. Clickable objects smaller than the minimum target size of 24 pixels wide by 24 pixels tall can make accurate interaction difficult for learners. Ensure interactive elements meet the minimum target size or have enough space around them. (2.5.8 Target Size [Minimum])
- Keep it simple. Fast, complex, or nonessential interactivity can increase cognitive load. To boost accessibility, synchronize your interactions with text or narration, allow learners to turn interactivity off, and ensure interactions align with learning objectives.
Understand Compatibility
Advanced JavaScript API is exclusive to Storyline 360 as of March 2025. While you can open, edit, and publish projects that use this API in earlier versions of Storyline 360, the code will break.