@@ -178,6 +178,7 @@ Object.defineProperty(Player, "previousFrameIndex", {
178178 get ( ) {
179179 var index = this . animator . running ? this . targetFrameIndex : this . currentFrameIndex ;
180180
181+ // Returns the previous non-hidden frame
181182 var prevFrame = index ;
182183 while ( ( prevFrame = ( prevFrame + this . presentation . frames . length - 1 ) % this . presentation . frames . length ) != index ) {
183184 if ( this . presentation . frames [ prevFrame ] . showInFrameList )
@@ -189,7 +190,14 @@ Object.defineProperty(Player, "previousFrameIndex", {
189190Object . defineProperty ( Player , "nextFrameIndex" , {
190191 get ( ) {
191192 var index = this . animator . running ? this . targetFrameIndex : this . currentFrameIndex ;
192-
193+
194+ // Check first if this is a sub-frame.
195+ // If it is, the next frame should be its parent
196+ var parent = this . parentFrameIndex ( index ) ;
197+ if ( parent > - 1 )
198+ return parent ;
199+
200+ // Not a sub-frame, returns the next non-hidden frame
193201 var nextFrame = index ;
194202 while ( ( nextFrame = ( nextFrame + 1 ) % this . presentation . frames . length ) != index ) {
195203 console . dir ( this . presentation . frames [ nextFrame ] ) ;
@@ -199,6 +207,24 @@ Object.defineProperty(Player, "nextFrameIndex", {
199207 }
200208} ) ;
201209
210+ /*
211+ * Returns the parent frame of the frame at index if it is a sub-frame.
212+ * Otherwise, returns -1.
213+ *
214+ * Sub-frames are identified by their id of the form parentFrameId/subFrameId
215+ */
216+ Player . parentFrameIndex = function ( index ) {
217+ var frameId = this . presentation . frames [ index ] . frameId ;
218+ var pos = frameId . lastIndexOf ( "/" ) ;
219+ if ( pos === - 1 ) // Not a sub-frame
220+ return - 1 ;
221+
222+ var parentFrameId = frameId . substring ( 0 , pos ) ;
223+ return this . presentation . frames . findIndex ( frame => {
224+ return frame . frameId === parentFrameId ;
225+ } ) ;
226+ } ;
227+
202228Player . showCurrentFrame = function ( ) {
203229 this . viewport . setAtStates ( this . currentFrame . cameraStates ) . update ( ) ;
204230 this . emit ( "frameChange" ) ;
0 commit comments