Forum Discussion
Vertical Storyline Scrolling
- 8 months ago
Thank you for clarifying. I see you have two additional buttons (Layer 1 and Layer 2) on the base layer that remain visible on each layer. The issue isn’t with the code itself, but rather with those buttons triggering actions and maintaining focus. This focus precedence prevents the layer from scrolling to the top content as expected. These buttons don’t need to be visible on other layers, as they’re redundant — you already have duplicate buttons on each layer for navigating back and forth. I’ve modified your file so that the JavaScript runs on each layer and changes the state of whichever base layer button gets clicked first to 'Hidden'. Preview the file and let me know if the issue is resolved.
Hi Ange ,
That's a nice workaround, but in this particular case, we don't need to overcomplicate it. Since the scroll behavior is automatically applied by Storyline at the slide level, just target the slide container directly and scroll it to the top like this:
document.querySelector('#slide').scrollTop = 0;
Let's say you just want to do the opposite — scroll to the bottom instead:
var slide = document.querySelector('#slide');
slide.scrollTop = slide.scrollHeight - slide.clientHeight;
scrollHeight: total scrollable content height
clientHeight: visible height of the element
So, the difference gives you the scroll position for the bottom.
Thank you! This is great and it was so easy! It works for the slides, but not for the layers. I tried using CoPilot to get javascript for the layers, and that doesn't work either. Any suggestions?
- Nedim8 months agoCommunity Member
Your original .story file didn’t have any layers. If you're using a different version with layers, please share it and let us know what issue you're trying to solve.
Technically, all layers sit inside the same container (<div id="slide">), so the scrollbar you see stays the same across the course — it's based on the overall project height.
I moved the text box on the final slide to a layer and used the same line of code — it worked.- DanielleForm3308 months agoCommunity Member
I must be doing something wrong, so thank you for your help! This is not something I'm super familiar with. Your initial suggestion worked perfectly for our guidelines without layers, so then I went and tried to update the guidelines that include layers and can't get it to work. Maybe I'm setting the trigger incorrectly. Here is a pretty bare example that shows my issue and layers not starting at the top.
- Nedim8 months agoCommunity Member
Thank you for clarifying. I see you have two additional buttons (Layer 1 and Layer 2) on the base layer that remain visible on each layer. The issue isn’t with the code itself, but rather with those buttons triggering actions and maintaining focus. This focus precedence prevents the layer from scrolling to the top content as expected. These buttons don’t need to be visible on other layers, as they’re redundant — you already have duplicate buttons on each layer for navigating back and forth. I’ve modified your file so that the JavaScript runs on each layer and changes the state of whichever base layer button gets clicked first to 'Hidden'. Preview the file and let me know if the issue is resolved.
Related Content
- 3 months ago
- 6 months ago
- 10 months ago