-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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 player.currentWidth
and player.currentHeight
* methods for getting computed style
#3144
Conversation
Add `player.currentWidth` and `player.currentHeight`* methods for getting computed style ## Specific Changes proposed API methods: Component Component.prototype.currentDimension(widthOrHeight) -> Number - It takes a string value of either width or height to return back the appropriate value Component.prototype.currentDimensions() -> Object{width: Number, height: Number} - Returns an object with width and height properties Component.prototype.currentHeight() -> Number - Delegates to Component#currentDimension to get back the height value Component.prototype.currentWidth() -> Number - Delegates to Component#currentDimension to get back the width value ## Requirements Checklist - [ X ] Feature implemented / Bug fixed - [ X ] If necessary, more likely in a feature request than a bug fix - [ X ] Unit Tests updated or fixed - [ ] Docs/guides updated - [ ] Example created ([starter template on JSBin](http://jsbin.com/axedog/edit?html,output)) - [ ] Reviewed by Two Core Contributors
Thanks. Sorry it's taken so long to take a look. At a quick glance, this looks good. I'll make some more in-depths comments tomorrow. |
@gkatsev you're welcome 👍 after your full review, I am going to fix issues. |
return false; | ||
} | ||
|
||
if (typeof window.getComputedStyle !== 'undefined') { |
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.
safer to check that it's equal to "function"
.
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.
ok.
I made some comments. Let me know if you have questions or need any help! |
@gkatsev I fixed issues. |
LGTM, thanks. |
@videojs/core-committers anyone else care to do a code review? |
|
||
if (typeof window.getComputedStyle === 'function') { | ||
const computedStyle = window.getComputedStyle(this.el_); | ||
computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[ widthOrHeight ]; |
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.
Very minor style comment: spaces inside [
and ]
.
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.
This can be fixed during merge; so, ignore me!
LGTM |
@defli thanks for your help! Looking forward to more contributions from you :) |
Description
Add
player.currentWidth
andplayer.currentHeight
* methods for getting computed styleSpecific Changes proposed
API methods:
Component
Component.prototype.currentDimension(widthOrHeight) -> Number - It takes a string value of either width or height to return back the appropriate value
Component.prototype.currentDimensions() -> Object{width: Number, height: Number} - Returns an object with width and height properties
Component.prototype.currentHeight() -> Number - Delegates to Component#currentDimension to get back the height value
Component.prototype.currentWidth() -> Number - Delegates to Component#currentDimension to get back the width value
Player - We probably don't need to make any changes in the player because it extends from component and will inherit the functionality from it.
Requirements Checklist