Add more bindings for media element properties#3650
Add more bindings for media element properties#3650Rich-Harris merged 4 commits intosveltejs:masterfrom
Conversation
|
I also wanted to support So my question: what should the following do? <video on:resize={handleResize}/>Should |
0d057dc to
ee30d65
Compare
ee30d65 to
ed4f89d
Compare
|
Apologies for the delay — this is excellent, thank you. I'm not sure I understand about the |
|
Yes, I thought it could conflict with the So the I think the simplest fix would be:
For example: <video bind:videoWidth bind:offsetWidth on:resize="fn">should:
I'll whip up a PR. 😉 |
This adds read-only bindings for
seekingandendedto<audio>and<video>elements.These can be used to build a custom video UI, similar to the media elements example. For example:
endedproperty can be used to show a replay button instead of a regular play/pause button:seekingproperty can be used to show a loading spinner while the media element is seeking.I also noticed that the current compiler would generate code for
bind:volumelike this:However, if
ctx.volumeis stillundefined, then this would throw aTypeErrorbecause it's not a number between 0 and 1 (spec).To fix this, I've added an
!isNaN(ctx.volume)check, so we don't set an invalid value when mounting. I've also refactored the code rendering for bindings a bit to make it easier to add such "mount conditions", similar to how we add "update conditions". 🙂