@@ -2201,13 +2201,13 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
22012201 for ( var i = 0 ; i < frameList . length ; i ++ ) {
22022202 var computedFrame ;
22032203
2204- if ( frameList [ i ] . name ) {
2204+ if ( frameList [ i ] . type === 'byname' ) {
22052205 // If it's a named frame, compute it:
2206- computedFrame = Plots . computeFrame ( gd , frameList [ i ] . name ) ;
2206+ computedFrame = Plots . computeFrame ( gd , frameList [ i ] . data . name ) ;
22072207 } else {
22082208 // Otherwise we must have been given a simple object, so treat
22092209 // the input itself as the computed frame.
2210- computedFrame = frameList [ i ] . frame ;
2210+ computedFrame = frameList [ i ] . data ;
22112211 }
22122212
22132213 var frameOpts = getFrameOpts ( i ) ;
@@ -2219,7 +2219,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
22192219
22202220 var nextFrame = {
22212221 frame : computedFrame ,
2222- name : frameList [ i ] . name || computedFrame . name ,
2222+ name : computedFrame . name ,
22232223 frameOpts : frameOpts ,
22242224 transitionOpts : transitionOpts ,
22252225 } ;
@@ -2344,34 +2344,47 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
23442344 var isSingleFrame = ! allFrames && ! isFrameArray && Lib . isPlainObject ( frameOrGroupNameOrFrameList ) ;
23452345
23462346 if ( isSingleFrame ) {
2347- frameList . push ( setTransitionConfig ( {
2348- frame : Lib . extendFlat ( { } , frameOrGroupNameOrFrameList )
2349- } ) ) ;
2347+ // In this case, a simple object has been passed to animate.
2348+ frameList . push ( {
2349+ type : 'object' ,
2350+ data : setTransitionConfig ( Lib . extendFlat ( { } , frameOrGroupNameOrFrameList ) )
2351+ } ) ;
23502352 } else if ( allFrames || typeof frameOrGroupNameOrFrameList === 'string' ) {
2353+ // In this case, null or undefined has been passed so that we want to
2354+ // animate *all* currently defined frames
23512355 for ( i = 0 ; i < trans . _frames . length ; i ++ ) {
23522356 frame = trans . _frames [ i ] ;
23532357
23542358 if ( allFrames || frame . group === frameOrGroupNameOrFrameList ) {
2355- frameList . push ( setTransitionConfig ( { name : frame . name } ) ) ;
2359+ frameList . push ( {
2360+ type : 'byname' ,
2361+ data : setTransitionConfig ( { name : frame . name } )
2362+ } ) ;
23562363 }
23572364 }
23582365 } else if ( isFrameArray ) {
23592366 for ( i = 0 ; i < frameOrGroupNameOrFrameList . length ; i ++ ) {
23602367 var frameOrName = frameOrGroupNameOrFrameList [ i ] ;
23612368 if ( typeof frameOrName === 'string' ) {
2362- frameList . push ( setTransitionConfig ( { name : frameOrName } ) ) ;
2369+ // In this case, there's an array and this frame is a string name:
2370+ frameList . push ( {
2371+ type : 'byname' ,
2372+ data : setTransitionConfig ( { name : frameOrName } )
2373+ } ) ;
23632374 } else {
2364- frameList . push ( setTransitionConfig ( {
2365- frame : Lib . extendFlat ( { } , frameOrName )
2366- } ) ) ;
2375+ frameList . push ( {
2376+ type : 'object' ,
2377+ data : setTransitionConfig ( Lib . extendFlat ( { } , frameOrName ) )
2378+ } ) ;
23672379 }
23682380 }
23692381 }
23702382
23712383 // Verify that all of these frames actually exist; return and reject if not:
23722384 for ( i = 0 ; i < frameList . length ; i ++ ) {
2373- if ( frameList [ i ] . name && ! trans . _frameHash [ frameList [ i ] . name ] ) {
2374- Lib . warn ( 'animate failure: frame not found: "' + frameList [ i ] . name + '"' ) ;
2385+ frame = frameList [ i ] ;
2386+ if ( frame . type === 'byname' && ! trans . _frameHash [ frame . data . name ] ) {
2387+ Lib . warn ( 'animate failure: frame not found: "' + frame . data . name + '"' ) ;
23752388 reject ( ) ;
23762389 return ;
23772390 }
0 commit comments