Skip to content

Commit 15e9a2d

Browse files
committed
Improve code, DEV-1618
1 parent a2b3555 commit 15e9a2d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

view/frontend/web/js/video-background-mixin.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ define([
1919
vimeoPattern.test(url);
2020
}
2121

22+
function getValidDimension(value, fallback) {
23+
if (!value || parseFloat(value) === 0) {
24+
return fallback;
25+
}
26+
return value;
27+
}
28+
2229
return function (config, element) {
2330
const videoElementContainer = $(element);
2431
const videoElement = videoElementContainer[0];
2532
const videoElementStyles = window.getComputedStyle(element);
26-
const height = videoElementStyles.minHeight || '300px';
27-
const width = videoElementStyles.width || '400px';
33+
const height = getValidDimension(videoElementStyles.minHeight, '300px');
34+
const width = getValidDimension(videoElementStyles.width, '400px');
2835

2936
if (videoElementContainer.data('background-type') !== 'video') {
3037
originalWidget(config, element);

0 commit comments

Comments
 (0)