Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setTimeout(() => {
const
wrapperWidth = Number.parseInt(this.els.wrapper.style.width)
, wrapperHeight = Number.parseInt(this.els.wrapper.style.height)
, preComputedHeight = wrapperWidth / this.options.aspectRatio
;
if (preComputedHeight >= wrapperHeight) { // based on wrapperWidth
addStyles(this.els.videoWrapperForConstraintRatio, {
width: wrapperWidth + 'px',
height: preComputedHeight + 'px',
});
} else { // based on wrapperHeight
addStyles(this.els.videoWrapperForConstraintRatio, {
width: wrapperHeight * this.options.aspectRatio + 'px',
height: wrapperHeight + 'px',
});
}
}, 0);
}
, _changeStyle = () => {
const
containerRectWidth = containerRect().width
, containerRectHeight = containerRect().height
;
if (_judgePhoneOrientation() === this.options.orientation) {
addStyles(this.els.wrapper, {
width: containerRectWidth + 'px',
height: containerRectHeight + 'px',
transform: '',
});
} else {
// Adjust the video orientation
addStyles(this.els.wrapper, {
width: containerRectHeight + 'px',
height: containerRectWidth + 'px',
transform: 'rotate(-90deg)',
});
}
// set videoWrapperForConstraintRatio width&height
setTimeout(() => {
const
, _changeOrientation = () => {
window.removeEventListener(_orientationchangeEvt, _changeOrientation);
setTimeout(() => {
_changeStyle();
window.addEventListener(_orientationchangeEvt, _changeOrientation, false);
}, 400);
}
;
if (this.options.disableRotation) {
_changeStyle();
window.addEventListener(_orientationchangeEvt, _changeOrientation, false);
} else {
addStyles(this.els.wrapper, {
width: containerRect().width + 'px',
height: containerRect().height + 'px',
});
}
};
}