From 15ba23f5cffa3c82efadd990915eed1df1143ffb Mon Sep 17 00:00:00 2001 From: Bruno Imbrizi Date: Wed, 15 Feb 2017 11:18:21 +0000 Subject: [PATCH] return last point until next point has started --- src/storyline.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/storyline.js b/src/storyline.js index 652babf..4e44d3e 100644 --- a/src/storyline.js +++ b/src/storyline.js @@ -95,14 +95,17 @@ function getPointInStoryline( storyline, t, value ) { if( !storyline[ value ] ) return null; + var last = null; + for( var j = 0; j < storyline[ value ].length; j++ ) { var e = storyline[ value ][ j ]; - if( e.start <= t && e.end > t ) { - return e; + if( e.start <= t) { + last = e; + if ( e.end > t ) return e; } } - return null; + return last; }