-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Emit plotly_animatingframe event on animated frames #953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1683005
3632488
32d9273
d639e19
627c8e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2219,7 +2219,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) { | |
|
||
var nextFrame = { | ||
frame: computedFrame, | ||
name: frameList[i].name, | ||
name: frameList[i].name || computedFrame.name, | ||
frameOpts: frameOpts, | ||
transitionOpts: transitionOpts, | ||
}; | ||
|
@@ -2274,6 +2274,8 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) { | |
var newFrame = trans._currentFrame = trans._frameQueue.shift(); | ||
|
||
if(newFrame) { | ||
gd.emit('plotly_animatingframe', newFrame.name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you thought about adding more fields to the event data? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. I have nothing against that since there's not another way to query frames by name short of looking it up yourself in the input data. What other fields do you think are relevant? I see:
Maybe all of them? They're just references, so not really any extra cost. Could pass as an object. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making the event data an object seems like the way to go in case we want to add more stuff in their at some point. |
||
|
||
trans._lastFrameAt = Date.now(); | ||
trans._timeToNext = newFrame.frameOpts.duration; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do need a fallback here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a bad point. I can move that elsewhere (being careful not to mutate the user input itself) for this particular case. (It's the case when a plain object is provided instead of the name of a frame.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to move it. I was just curious.
How hard would it to be to add a test for that case? If not so hard, then let's add one,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Moved. I added an extra container for frames internally so that I'm not cramming any extra properties together that could conceivably conflict.