@@ -94,16 +94,20 @@ define([
94
94
options : {
95
95
videoData : '' ,
96
96
videoSettings : '' ,
97
- optionsVideoData : ''
97
+ optionsVideoData : '' ,
98
+ vimeoJSFrameworkLoaded : false
98
99
} ,
99
-
100
+ onVimeoJSFramework : function ( ) { } ,
100
101
PV : 'product-video' , // [CONST]
101
102
VU : 'video-unplayed' ,
102
103
PVLOADED : 'fotorama__product-video--loaded' , // [CONST]
104
+ PVLOADING : 'fotorama__product-video--loading' , // [CONST]
103
105
VID : 'video' , // [CONST]
104
106
VI : 'vimeo' , // [CONST]
105
107
FTVC : 'fotorama__video-close' ,
106
108
FTAR : 'fotorama__arr' ,
109
+ fotoramaSpinner : 'fotorama__spinner' ,
110
+ fotoramaSpinnerShow : 'fotorama__spinner--show' ,
107
111
TI : 'video-thumb-icon' ,
108
112
isFullscreen : false ,
109
113
FTCF : '[data-gallery-role="fotorama__fullscreen-icon"]' ,
@@ -147,7 +151,6 @@ define([
147
151
* @private
148
152
*/
149
153
_setOptions : function ( options ) {
150
-
151
154
if ( options . videoData && options . videoData . length ) {
152
155
this . options . videoData = options . videoData ;
153
156
}
@@ -402,6 +405,14 @@ define([
402
405
403
406
element . async = true ;
404
407
element . src = 'https://secure-a.vimeocdn.com/js/froogaloop2.min.js' ;
408
+
409
+ /**
410
+ * Vimeo js framework on load callback.
411
+ */
412
+ element . onload = function ( ) {
413
+ this . onVimeoJSFramework ( ) ;
414
+ this . vimeoJSFrameworkLoaded = true ;
415
+ } . bind ( this ) ;
405
416
scriptTag . parentNode . insertBefore ( element , scriptTag ) ;
406
417
} ,
407
418
@@ -620,15 +631,41 @@ define([
620
631
} ,
621
632
622
633
/**
623
- *
624
- * @param {Event } event
625
634
* @private
626
635
*/
627
- _clickHandler : function ( event ) {
628
- if ( $ ( event . target ) . hasClass ( this . VU ) && $ ( event . target ) . find ( 'iframe' ) . length === 0 ) {
636
+ _showLoader : function ( ) {
637
+ var spinner = this . fotoramaItem . find ( '.' + this . fotoramaSpinner ) ;
638
+
639
+ spinner . addClass ( this . fotoramaSpinnerShow ) ;
640
+ this . fotoramaItem . data ( 'fotorama' ) . activeFrame . $stageFrame . addClass ( this . PVLOADING ) ;
641
+ } ,
642
+
643
+ /**
644
+ * @private
645
+ */
646
+ _hideLoader : function ( ) {
647
+ var spinner = this . fotoramaItem . find ( '.' + this . fotoramaSpinner ) ;
648
+
649
+ spinner . removeClass ( this . fotoramaSpinnerShow ) ;
650
+ this . fotoramaItem . data ( 'fotorama' ) . activeFrame . $stageFrame . removeClass ( this . PVLOADING ) ;
651
+ } ,
629
652
653
+ /**
654
+ * @param {Event } event
655
+ * @private
656
+ */
657
+ _clickHandler : function ( event ) { if ( $ ( event . target ) . hasClass ( this . VU ) && $ ( event . target ) . find ( 'iframe' ) . length === 0 ) {
630
658
$ ( event . target ) . removeClass ( this . VU ) ;
631
- $ ( event . target ) . find ( '.' + this . PV ) . productVideoLoader ( ) ;
659
+
660
+ if ( this . vimeoJSFrameworkLoaded ) {
661
+ $ ( event . target ) . find ( '.' + this . PV ) . productVideoLoader ( ) ;
662
+ } else {
663
+ this . _showLoader ( ) ;
664
+ this . onVimeoJSFramework = function ( ) {
665
+ $ ( event . target ) . find ( '.' + this . PV ) . productVideoLoader ( ) ;
666
+ this . _hideLoader ( ) ;
667
+ } . bind ( this ) ;
668
+ }
632
669
633
670
$ ( '.' + this . FTAR ) . addClass ( this . isFullscreen ? 'fotorama__arr--shown' : 'fotorama__arr--hidden' ) ;
634
671
}
@@ -686,6 +723,7 @@ define([
686
723
}
687
724
688
725
$wrapper . find ( '.' + this . PVLOADED ) . removeClass ( this . PVLOADED ) ;
726
+ this . _hideLoader ( ) ;
689
727
690
728
$wrapper . find ( '.' + this . PV ) . each ( function ( ) {
691
729
var $item = $ ( this ) . parent ( ) ,
0 commit comments