-
Notifications
You must be signed in to change notification settings - Fork 88
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
✨ Added optional onDraw method to play
to run after the _render call.
#266
✨ Added optional onDraw method to play
to run after the _render call.
#266
Conversation
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.
Hey Abid, thanks so much for contributing. Sorry for the delay, got a bit sidetracked with other stuff. The onDraw
method should run every visual frame (each time we call _render
to draw the frame onto the canvas).
play
to run after the _render call.
I updated the logic, let me know if I'm on the right track. 🙇 |
spec/unit/movie/movie.spec.ts
Outdated
it('should call user provided `onDraw` after drawing', async function () { | ||
// 1a. Force currentTime to 0 | ||
mockTime(0) | ||
|
||
// 1b. Layer must be inactive to start | ||
const layer = movie.layers[0] | ||
layer.active = false | ||
|
||
// 2a. Prepare options object with onDraw callback | ||
const options = jasmine.createSpyObj('options', ['onDraw']) | ||
|
||
// 2b. Play one frame at the beginning of the movie with the spy options | ||
await movie.play(options) | ||
|
||
// 3. Make sure onDraw was called | ||
expect(options.onDraw).toHaveBeenCalledTimes(1) | ||
}) | ||
|
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.
Can you move this to the playback section?
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.
I updated the test to try to use the pattern used in the playback section
, but still very basic test. b88be92#diff-f3f0599beaa55e219f66852cc9f533a3c064e0d28d43b550612db7c3987ba0cdR278-R298
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.
Thank you so much!!
Description
Implements an optional callback that gets run after every
Movie._render()
resolves: #230