@@ -2201,13 +2201,13 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
2201
2201
for ( var i = 0 ; i < frameList . length ; i ++ ) {
2202
2202
var computedFrame ;
2203
2203
2204
- if ( frameList [ i ] . name ) {
2204
+ if ( frameList [ i ] . type === 'byname' ) {
2205
2205
// 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 ) ;
2207
2207
} else {
2208
2208
// Otherwise we must have been given a simple object, so treat
2209
2209
// the input itself as the computed frame.
2210
- computedFrame = frameList [ i ] . frame ;
2210
+ computedFrame = frameList [ i ] . data ;
2211
2211
}
2212
2212
2213
2213
var frameOpts = getFrameOpts ( i ) ;
@@ -2219,7 +2219,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
2219
2219
2220
2220
var nextFrame = {
2221
2221
frame : computedFrame ,
2222
- name : frameList [ i ] . name || computedFrame . name ,
2222
+ name : computedFrame . name ,
2223
2223
frameOpts : frameOpts ,
2224
2224
transitionOpts : transitionOpts ,
2225
2225
} ;
@@ -2344,34 +2344,47 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
2344
2344
var isSingleFrame = ! allFrames && ! isFrameArray && Lib . isPlainObject ( frameOrGroupNameOrFrameList ) ;
2345
2345
2346
2346
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
+ } ) ;
2350
2352
} 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
2351
2355
for ( i = 0 ; i < trans . _frames . length ; i ++ ) {
2352
2356
frame = trans . _frames [ i ] ;
2353
2357
2354
2358
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
+ } ) ;
2356
2363
}
2357
2364
}
2358
2365
} else if ( isFrameArray ) {
2359
2366
for ( i = 0 ; i < frameOrGroupNameOrFrameList . length ; i ++ ) {
2360
2367
var frameOrName = frameOrGroupNameOrFrameList [ i ] ;
2361
2368
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
+ } ) ;
2363
2374
} else {
2364
- frameList . push ( setTransitionConfig ( {
2365
- frame : Lib . extendFlat ( { } , frameOrName )
2366
- } ) ) ;
2375
+ frameList . push ( {
2376
+ type : 'object' ,
2377
+ data : setTransitionConfig ( Lib . extendFlat ( { } , frameOrName ) )
2378
+ } ) ;
2367
2379
}
2368
2380
}
2369
2381
}
2370
2382
2371
2383
// Verify that all of these frames actually exist; return and reject if not:
2372
2384
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 + '"' ) ;
2375
2388
reject ( ) ;
2376
2389
return ;
2377
2390
}
0 commit comments