Skip to content

Commit 7f007f9

Browse files
committed
Fixed video behavior on storefront
1 parent bcf996c commit 7f007f9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ define([
102102
FTVC: 'fotorama__video-close',
103103
FTAR: 'fotorama__arr',
104104
isFullscreen: 0,
105+
inFullscreen: false,
105106
Base: 0, //on check for video is base this setting become true if there is any video with base role
106107
MobileMaxWidth: 767,
107108
GP: 'gallery-placeholder', //gallery placeholder class is needed to find and erase <script> tag
@@ -113,6 +114,7 @@ define([
113114
_init: function () {
114115
if (this._checkForVideoExist()) {
115116
this._checkFullscreen();
117+
this._listenForFullscreen();
116118
this._checkForVimeo();
117119
this._isVideoBase();
118120
this._initFotoramaVideo();
@@ -130,6 +132,19 @@ define([
130132
}
131133
},
132134

135+
/**
136+
*
137+
* @private
138+
*/
139+
_listenForFullscreen: function () {
140+
$(this.element).on('fotorama:fullscreenenter', $.proxy(function () {
141+
this.inFullscreen = true;
142+
}, this));
143+
$(this.element).on('fotorama:fullscreenexit', $.proxy(function () {
144+
this.inFullscreen = false;
145+
}, this));
146+
},
147+
133148
/**
134149
*
135150
* @param {Object} inputData
@@ -502,6 +517,13 @@ define([
502517
$('.' + self.FTAR).addClass('hidden-video');
503518
}
504519
});
520+
521+
if (this.inFullscreen) {
522+
$(this.element).data('fotorama').activeFrame.$stageFrame[0].click();
523+
}
524+
$(this.element).on('fotorama:fullscreenenter', $.proxy(function () {
525+
$(this.element).data('fotorama').activeFrame.$stageFrame[0].click();
526+
}, this));
505527
this._handleBaseVideo(fotorama, number); //check for video is it base and handle it if it's base
506528
},
507529

@@ -533,7 +555,13 @@ define([
533555
}, this), 50);
534556
} else { //if not a vimeo - play it immediately with a little lag in case for fotorama fullscreen
535557
setTimeout($.proxy(function () {
558+
fotorama.requestFullScreen();
536559
$(this.element).data('fotorama').activeFrame.$stageFrame[0].click();
560+
$('.fotorama__fullscreen-icon').css({
561+
opacity: '1',
562+
visibility: 'visible',
563+
display: 'block'
564+
});
537565
this.Base = false;
538566
}, this), 50);
539567
}

0 commit comments

Comments
 (0)