Using JavaScript to hide/toggle the sidebar menu

Dec 03, 2018

Hello,

I'm playing around with a couple of the JavaScript examples that we featured in JavaScript Tricks for Articulate Storyline, from eLearning Brothers (https://elearningbrothers.com/blog/javascript-tricks-articulate-storyline-3-360/).

I'm working with the fancy toggle example and trying to set the sidebar to be hidden initially, and when the user clicks the hamburger icon in my custom menu, it toggles the sidebar on.  In order for the script to work, the Menu must be switched on in the player, but obviously that means it shows up on the screen. I want the menu to be active, but just hidden at first.

So far my attempts haven't yielded much success. Has anyone had any success in doing something similar?

5 Replies
Gemz Nunn

Update: I figured it out! 

I created a new script and added it to the first screen of the Storyline 3 file, executing it when timeline starts. The script sets the opacity and width of the sidebar to the same settings used by the toggle script when hiding it.

Here's the code I used in case anyone else wants to use it:

// Load Storyline player
var player = GetPlayer();
// Set window.mw to be equal to .area-secondary width
if(!window.mw) window.mw = $(".area-secondary").width()
// Set .area-secondary to hidden 
$('.area-secondary').css({
'width': '-='+mw,
opacity: 0
})

This discussion is closed. You can start a new discussion or contact Articulate Support.