From d228a13031590576a3f9eaa50ede19c763a774be Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 28 Jul 2019 07:14:57 +0000 Subject: [PATCH] assets/scripts.js: Implement disableImmediateSceneTransition Allow navigating from dead-end segments without waiting for the segment to end. --- assets/scripts.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/scripts.js b/assets/scripts.js index 60518d2..ea9fca0 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -166,16 +166,15 @@ function addZones(segmentId) { setNextSegment(defaultSegmentId); } -var currentChoices = []; +var currentChoiceMoment = null; function addChoices(r) { - currentChoices = []; + currentChoiceMoment = r; nextChoice = -1; var ul = newList("choices"); document.getElementById("choiceCaption").innerHTML = ''; if (!r) return; - currentChoices = r.choices; nextChoice = r.defaultChoiceIndex; let index = 0; @@ -209,7 +208,7 @@ function momentUpdate(m, ms) { function momentEnd(m, seeked) { console.log('momentEnd', m, seeked); if (m.choices) { - addChoices(0); + addChoices(null); document.getElementById("progress").style.width = 0; } } @@ -322,7 +321,7 @@ function ontimeupdate(evt) { function playNextSegment() { if (nextChoice >= 0) { - let x = currentChoices[nextChoice]; + let x = currentChoiceMoment.choices[nextChoice]; let choiceId = x.segmentId ? x.segmentId : (x.sg ? x.sg : x.id); var segmentId = findSegment(choiceId); console.log('choice', choiceId, 'nextSegment', segmentId); @@ -475,6 +474,8 @@ function seek(ms) { function choice(choiceIndex) { nextChoice = choiceIndex; newList("choices"); + if (!currentChoiceMoment.config.disableImmediateSceneTransition) + playNextSegment(); } function applyImpression(impressionData) {