bbc / VideoContext

An experimental HTML5 & WebGL video composition and rendering API.
http://bbc.github.io/VideoContext/
Apache License 2.0
1.33k stars 157 forks source link

Improve JSDoc comments for src/VideoContext.js and how options default are handled #139

Closed germain-gg closed 5 years ago

germain-gg commented 5 years ago

I noticed that the way that options default were handled could be a bit problematic.

Essentially it is currently leveraging the ES6 default parameter feature. The big problem is that if you give an option hash that has only one of the option defined. All the other defaults will be lost. With this new approach we now take advantage of destructuring and default parameters.

I have also created a VideoContext.EVENTS hash that is aligned with VideoContext.STATE.

And last but not least, I have updated and fix some of the JSDoc comments. It still isn't perfect but I feel like that already hugely improve documentation.

PTaylour commented 5 years ago

Good spot! Good timing too as this fixes https://github.com/bbc/VideoContext/issues/135

germain-gg commented 5 years ago

Is _endOnLastSourceEnd no longer set?

VideoContext/src/videocontext.js

Line 864 in 9310f43

if (this._currentTime > this.duration && this._endOnLastSourceEnd) {

Oops, you're right! on Line 67 I set this.endOnLastSourceEnd but this is incorrect. It should be with a dangling underscore.

germain-gg commented 5 years ago

Thanks for the heads up, this is now fixed

germain-gg commented 5 years ago

Yeah, looks good to me!