Forum Discussion
Force the menu to only show slides from selected scenes (not the whole project)
- 8 months ago
I think it looks just fine. Please email me at nedim.ramic@gmail.com so I can send you the .story file along with a few important details you should be aware of.
This is great Nedim! Could you share the .story file? This is exactly what I was looking for. Thank you!
Hello Joseph,
I've attached a .story file as a reference. This simple example includes a selection scene and two additional scenes. Each scene's visibility is controlled based on the user's selection on the selection slide. The JavaScript is placed in the Slide Master. If your project uses multiple Slide Masters, make sure the JS trigger is included in each one.
- If you add more scenes, make sure to:
- Create a variable for each new scene.
- Include each scene variable in the sceneMap object in the JavaScript code.
- If you rename the selection scene, update the code accordingly (e.g., ["Scene selection"] should reflect the new name).
- On the selection slide, if you add more buttons for new scenes, create triggers that update the corresponding scene variables, just like the existing triggers shown in the example file.
const sceneMap = {
"Scene 1": getVar("scene1"),
"Scene 2": getVar("scene2"),
// Add more as needed
};
// Get list of active (true) scenes
const activeScenes = ["Scene selection"]; // always keep this one
for (const [sceneTitle, isActive] of Object.entries(sceneMap)) {
if (isActive) {
activeScenes.push(sceneTitle);
}
}
const menuItems = document.querySelectorAll('.is-scene');
// Reset and control visibility
menuItems.forEach(menu => {
const title = menu.getAttribute('data-slide-title');
menu.parentElement.style.display = activeScenes.includes(title) ? "" : "none";
});
EDIT: My file won’t go through. I’ve tried many times, but the issue is on my end. If you don’t mind, please send an email to mailto:nedim.ramic@gmail.com and I’ll reply with the attached file. I’ll be off on a 10-day vacation starting next week, so hopefully I can send it to you before then. Sorry about that.