Skip to content
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

Add bindings for HTMLVideoElement.videoWidth and videoHeight #3927

Merged
merged 4 commits into from
Nov 15, 2019

Conversation

MattiasBuelens
Copy link
Contributor

This adds read-only bindings for videoWidth and videoHeight to <video> elements. These properties return the intrinsic size of the video, so you can for example resize a <canvas> to match the size of the video:

<video bind:videoWidth={w} bind:videoHeight={h}>
<canvas width={w} height={h}>

These bindings are updated whenever the <video> element fires a resize event. This caused a small issue, since we were already using the name resize internally to implement dimension bindings. Therefore, I've renamed that internal event to elementresize, so the video bindings can bind to the "regular" resize event. This does change the emit for dimension bindings slightly, since the name of the event is used for the generated handler (example).

Follow-up on #3650.

@Rich-Harris Rich-Harris merged commit 927fcbf into sveltejs:master Nov 15, 2019
@Rich-Harris
Copy link
Member

Brilliant, thank you!

@MattiasBuelens MattiasBuelens deleted the video-bindings branch November 15, 2019 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants