Skip to content

Commit 32d9273

Browse files
committed
Emit more useful data on plotly_animatingframe
1 parent 3632488 commit 32d9273

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/plot_api/plot_api.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,14 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
22742274
var newFrame = trans._currentFrame = trans._frameQueue.shift();
22752275

22762276
if(newFrame) {
2277-
gd.emit('plotly_animatingframe', newFrame.name);
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+
});
22782285

22792286
trans._lastFrameAt = Date.now();
22802287
trans._timeToNext = newFrame.frameOpts.duration;

test/jasmine/tests/animate_test.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,11 @@ describe('Test animate API', function() {
409409
describe('frame events', function() {
410410
it('emits an event when a frame is transitioned to', function(done) {
411411
var frames = [];
412-
gd.on('plotly_animatingframe', function(name) {
413-
frames.push(name);
412+
gd.on('plotly_animatingframe', function(data) {
413+
frames.push(data.name);
414+
expect(data.frame).not.toBe(undefined);
415+
expect(data.animation.frame).not.toBe(undefined);
416+
expect(data.animation.transition).not.toBe(undefined);
414417
});
415418

416419
Plotly.animate(gd, ['frame0', 'frame1', {name: 'test'}, {data: []}], {

0 commit comments

Comments
 (0)