]> _ Git - fluidbook-html5.git/commitdiff
wait #5425 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 Aug 2022 11:57:11 +0000 (13:57 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 Aug 2022 11:57:11 +0000 (13:57 +0200)
js/libs/fluidbook/fluidbook.support.js
js/libs/fluidbook/slideshow/fluidbook.slideshow.dummy.js

index 82b699503851118090abf6ba3ee42e85521e82d1..496e98811064e69fa2745061686148c0d7514096 100644 (file)
@@ -131,6 +131,9 @@ FluidbookSupport.prototype = {
             $(window).on('resize', function () {
                 resize();
             });
+            setInterval(function () {
+                $this.checkOrientation();
+            }, 1000);
         } else {
             if ("onorientationchange" in window) {
                 window.addEventListener('orientationchange', function () {
@@ -167,6 +170,7 @@ FluidbookSupport.prototype = {
         var o = this.getOrientation();
         if (o != this._orientation) {
             this._orientation = o;
+            $(this.fluidbook).trigger('fluidbook.orientationchange');
             resize();
         }
     }, getOrientation: function () {
index 920b073d2b8d318d5ad8dbd28313c332ce3722c2..77fc807d3251aab131b2ca802ac3933eb862080c 100644 (file)
@@ -1,10 +1,36 @@
 function FluidbookDummySlideshow(fluidbook) {
     this.fluidbook = fluidbook;
-
+    this.intervalHandle = null;
+    this.timeoutHandle = null;
+    this.initEvents();
 }
 
 FluidbookDummySlideshow.prototype = {
-    clear: function () {
+
+    initEvents: function () {
+        var $this = this;
+        $(this.fluidbook).on('fluidbook.orientationchange', function () {
+            setTimeout(function () {
+                if ($this.fluidbook.support.getOrientation() === 90) {
+                    $('.fb-slideshow-wrapper.dummy.fb-slideshow-inline .fb-slideshow').each(function () {
+                        if ($(this).data('init') === true) {
+                            $this.launchSlideshow($(this));
+                        } else {
+                            $this.initSlideshow($(this));
+                        }
+                    });
+                }
+            }, 2000);
+        });
+    },
+
+    clear: function (s) {
+        if ($(s).data('intervalHandle') !== undefined) {
+            clearRequestInterval($(s).data('intervalHandle'));
+        }
+        if ($(s).data('timeoutHandle') !== undefined) {
+            clearRequestTimeout($(s).data('timeoutHandle'));
+        }
     },
 
     initSlideshow: function (s) {
@@ -13,12 +39,20 @@ FluidbookDummySlideshow.prototype = {
         }
 
         var holder = $(s).find('.splide__list');
-        var $this = this;
         s.data('init', true);
 
         // Move first to end
         holder.append(holder.find('.fb-slideshow-slide:eq(0)'));
-        requestInterval(
+        this.launchSlideshow($(s));
+    },
+
+    launchSlideshow: function (s) {
+        this.clear(s);
+        var holder = $(s).find('.splide__list');
+        var $this = this;
+        holder.find('.fb-slideshow-slide').removeClass('show');
+        holder.find('.fb-slideshow-slide:eq(0)').addClass('show')
+        $(s).data('intervalHandle', requestInterval(
             function () {
                 if (!$(holder).is(':visible')) {
                     return;
@@ -30,14 +64,15 @@ FluidbookDummySlideshow.prototype = {
                 }
                 $(next).css({display: 'block', zIndex: 2});
 
-                requestTimeout(function () {
+                $(s).data('timeoutHandle', requestTimeout(function () {
                     $(next).addClass('show').one($this.fluidbook.support.getTransitionEndEvent(), function () {
                         $(holder).find('.fb-slideshow-slide.show').not(next).removeClass('show').css('display', 'none');
                         $(this).css({zIndex: '', display: ''});
                     });
-                }, 200);
+                }, 200));
 
-            }, parseFloat(this.fluidbook.settings.inlineSlideshowDuration) * 1000);
+            }, parseFloat($this.fluidbook.settings.inlineSlideshowDuration) * 1000)
+        );
     },
 
     resizeInline() {