1
0
mirror of https://github.com/videojs/video.js.git synced 2025-02-14 12:20:48 +02:00

fix: currentDimension can return 0 for fluid player on IE (#3738)

This is because IE returns 0 for both getComputedStyle and currentStyle.
However, offsetHeight and offsetWidth do contain the correct values we
want. So, if before returning in currentDimension the return value is
still zero, check the offset values.
This commit is contained in:
Gary Katsevman 2016-11-03 18:41:27 -04:00 committed by GitHub
parent 2e720afb65
commit 74cddcad73

View File

@ -1148,16 +1148,20 @@ class Component {
const computedStyle = window.getComputedStyle(this.el_);
computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[widthOrHeight];
} else if (this.el_.currentStyle) {
// ie 8 doesn't support computed style, shim it
// return clientWidth or clientHeight instead for better accuracy
}
// remove 'px' from variable and parse as integer
computedWidthOrHeight = parseFloat(computedWidthOrHeight);
// if the computed value is still 0, it's possible that the browser is lying
// and we want to check the offset values.
// This code also runs on IE8 and wherever getComputedStyle doesn't exist.
if (computedWidthOrHeight === 0) {
const rule = `offset${toTitleCase(widthOrHeight)}`;
computedWidthOrHeight = this.el_[rule];
}
// remove 'px' from variable and parse as integer
computedWidthOrHeight = parseFloat(computedWidthOrHeight);
return computedWidthOrHeight;
}