@@ -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
2206
computedFrame = Plots . computeFrame ( gd , frameList [ i ] . 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 ) ;
@@ -2274,6 +2274,15 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
2274
2274
var newFrame = trans . _currentFrame = trans . _frameQueue . shift ( ) ;
2275
2275
2276
2276
if ( newFrame ) {
2277
+ gd . emit ( 'plotly_animatingframe' , {
2278
+ name : newFrame . name ,
2279
+ frame : newFrame . frame ,
2280
+ animation : {
2281
+ frame : newFrame . frameOpts ,
2282
+ transition : newFrame . transitionOpts ,
2283
+ }
2284
+ } ) ;
2285
+
2277
2286
trans . _lastFrameAt = Date . now ( ) ;
2278
2287
trans . _timeToNext = newFrame . frameOpts . duration ;
2279
2288
@@ -2342,34 +2351,49 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
2342
2351
var isSingleFrame = ! allFrames && ! isFrameArray && Lib . isPlainObject ( frameOrGroupNameOrFrameList ) ;
2343
2352
2344
2353
if ( isSingleFrame ) {
2345
- frameList . push ( setTransitionConfig ( {
2346
- frame : Lib . extendFlat ( { } , frameOrGroupNameOrFrameList )
2347
- } ) ) ;
2354
+ // In this case, a simple object has been passed to animate.
2355
+ frameList . push ( {
2356
+ type : 'object' ,
2357
+ data : setTransitionConfig ( Lib . extendFlat ( { } , frameOrGroupNameOrFrameList ) )
2358
+ } ) ;
2348
2359
} else if ( allFrames || typeof frameOrGroupNameOrFrameList === 'string' ) {
2360
+ // In this case, null or undefined has been passed so that we want to
2361
+ // animate *all* currently defined frames
2349
2362
for ( i = 0 ; i < trans . _frames . length ; i ++ ) {
2350
2363
frame = trans . _frames [ i ] ;
2351
2364
2352
2365
if ( allFrames || frame . group === frameOrGroupNameOrFrameList ) {
2353
- frameList . push ( setTransitionConfig ( { name : frame . name } ) ) ;
2366
+ frameList . push ( {
2367
+ type : 'byname' ,
2368
+ name : frame . name ,
2369
+ data : setTransitionConfig ( { name : frame . name } )
2370
+ } ) ;
2354
2371
}
2355
2372
}
2356
2373
} else if ( isFrameArray ) {
2357
2374
for ( i = 0 ; i < frameOrGroupNameOrFrameList . length ; i ++ ) {
2358
2375
var frameOrName = frameOrGroupNameOrFrameList [ i ] ;
2359
2376
if ( typeof frameOrName === 'string' ) {
2360
- frameList . push ( setTransitionConfig ( { name : frameOrName } ) ) ;
2377
+ // In this case, there's an array and this frame is a string name:
2378
+ frameList . push ( {
2379
+ type : 'byname' ,
2380
+ name : frameOrName ,
2381
+ data : setTransitionConfig ( { name : frameOrName } )
2382
+ } ) ;
2361
2383
} else {
2362
- frameList . push ( setTransitionConfig ( {
2363
- frame : Lib . extendFlat ( { } , frameOrName )
2364
- } ) ) ;
2384
+ frameList . push ( {
2385
+ type : 'object' ,
2386
+ data : setTransitionConfig ( Lib . extendFlat ( { } , frameOrName ) )
2387
+ } ) ;
2365
2388
}
2366
2389
}
2367
2390
}
2368
2391
2369
2392
// Verify that all of these frames actually exist; return and reject if not:
2370
2393
for ( i = 0 ; i < frameList . length ; i ++ ) {
2371
- if ( frameList [ i ] . name && ! trans . _frameHash [ frameList [ i ] . name ] ) {
2372
- Lib . warn ( 'animate failure: frame not found: "' + frameList [ i ] . name + '"' ) ;
2394
+ frame = frameList [ i ] ;
2395
+ if ( frame . type === 'byname' && ! trans . _frameHash [ frame . data . name ] ) {
2396
+ Lib . warn ( 'animate failure: frame not found: "' + frame . data . name + '"' ) ;
2373
2397
reject ( ) ;
2374
2398
return ;
2375
2399
}
0 commit comments