Conversation
|
One thing to consider as well here is that we're going to get multiple |
This reverts commit e0ed0b5.
| let RESIZE_OBSERVER_AVAILABLE = options.ResizeObserver || window.ResizeObserver; | ||
|
|
||
| if (options.ResizeObserver === null) { | ||
| RESIZE_OBSERVER_AVAILABLE = false; |
There was a problem hiding this comment.
wouldn't this set RESIZE_OBSERVER_AVAILABLE to false even when one is available through window.ResizeObserver?
There was a problem hiding this comment.
Yup, the idea is if you wanted to disable the ResizeObserver for whatever reason you could pass in null.
There was a problem hiding this comment.
Gotcha. I'd suggest a comment over this block so it's clear for future readers 😄
| * @event Player#playerresize | ||
| * @type {EventTarget~Event} | ||
| */ | ||
| this.trigger('playerresize'); |
There was a problem hiding this comment.
I believe the event trigger would have worked in IE8 as well - since we're reverting this for the ResizeObserver and that's only available after IE8, is this a breaking change?
There was a problem hiding this comment.
We are falling back to using an iframe for playerresize events when ResizeObserver isn't available, currently, that's basically everywhere, though, chrome will be shipping ResizeObserver soon.
| this.player.on('playerresize', function() { | ||
| playerresizeCalled++; | ||
| }); | ||
| rm.resizeObserver_.observer(); |
There was a problem hiding this comment.
actually looks like you don't need this line at all
There was a problem hiding this comment.
I set this in the constructor of MyResizeObserver, calling it calls the observe handler which will trigger playerresize which we can then test. Maybe I should just make it a local variable to be more obvious what is going on.
There was a problem hiding this comment.
Ah, I see. I agree that making it a local variable will make it more clear
| assert.equal(playerresizeCalled, 1, 'playerresize was triggered'); | ||
|
|
||
| rm.dispose(); | ||
| }); |
There was a problem hiding this comment.
one good test to add would be a test that makes sure a resizeObserver is created when one is available on the window
There was a problem hiding this comment.
It would be nice but mocking out window is a pain :)
| let RESIZE_OBSERVER_AVAILABLE = options.ResizeObserver || window.ResizeObserver; | ||
|
|
||
| if (options.ResizeObserver === null) { | ||
| RESIZE_OBSERVER_AVAILABLE = false; |
There was a problem hiding this comment.
Gotcha. I'd suggest a comment over this block so it's clear for future readers 😄
| this.player.on('playerresize', function() { | ||
| playerresizeCalled++; | ||
| }); | ||
| rm.resizeObserver_.observer(); |
There was a problem hiding this comment.
Ah, I see. I agree that making it a local variable will make it more clear
misteroneill
left a comment
There was a problem hiding this comment.
One minor question that I don't think affects my approval of this PR. 👍
| return super.createEl('iframe', { | ||
| className: 'vjs-resize-manager' | ||
| }); | ||
| } |
There was a problem hiding this comment.
I believe the element will be created even when it's not needed. Should we suppress the creation of it when ResizeObserver is available?
There was a problem hiding this comment.
This line in the constructor will make it so no element is created if ResizeObserver is used: https://github.com/videojs/video.js/pull/4864/files#diff-8947c14c969c2d82a892c5fac0d0efd0R19
There was a problem hiding this comment.
Oh, I didn't notice that. Carry on. 👍
Updated based on comments and added docs.
ldayananda
left a comment
There was a problem hiding this comment.
Made a few small typo corrections, but at this point LGTM
|
QA-LGTM |
Use ResizeObserver when available for better and more performant resizing information, otherwise, fall back to a throttled
resizeevent on an iframe that's the size of the player.Allows a video.js user to disable this by setting
resizeManager: falseas an option since the component will not be initialized.This probably needs to revert #4800 (e0ed0b5) because we end up getting two
playerresizeevents with the dimension methods now.TODO: