]> _ Git - fluidbook-html5.git/commitdiff
fix #1710 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Dec 2017 18:09:39 +0000 (19:09 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Dec 2017 18:09:39 +0000 (19:09 +0100)
js/libs/fluidbook/fluidbook.interface.js
js/libs/fluidbook/fluidbook.resize.js

index fc46c8a64406d5d3f3a6f904a3300fe7d909b353..8833ab367167325bb753e08459cd7a489560a499 100644 (file)
@@ -11,6 +11,7 @@ function FluidbookInterface(fluidbook) {
 
 FluidbookInterface.prototype = {
     init: function () {
+        var $this = this;
         var res = '';
         if ($('html').hasClass('ltr')) {
             res += this.fluidbook.nav.getLink('interface-previous', '#', 'previous', '', '', '', true);
@@ -24,11 +25,28 @@ FluidbookInterface.prototype = {
         $(document).on('click', '#next', goNextPage);
         $(document).on('click', '#previous', goPreviousPage);
 
+        $(this.fluidbook).on('fluidbook.resize, fluidbook.resize.orientation', function () {
+            $this.checkHidden();
+        });
+
         this.initArrowsVisibilityManagement();
     },
 
+    checkHidden: function () {
+        if (!this.autoHideArrows()) {
+            this.displayInterface();
+        } else {
+            this.resetTimeout();
+        }
+    },
+
+    areArrowsOverlapingPublication: function () {
+        //return true;
+        return $("#fluidbook").get(0).getBoundingClientRect().left < $("#previous").get(0).getBoundingClientRect().width;
+    },
+
     autoHideArrows: function () {
-        if (!this.fluidbook.resize.reduceHorizontalMargins()) {
+        if (!this.fluidbook.resize.reduceHorizontalMargins() || !this.areArrowsOverlapingPublication()) {
             return false;
         }
         return true;
@@ -54,13 +72,16 @@ FluidbookInterface.prototype = {
         });
 
         $(this.fluidbook).on('fluidbook.ready', function () {
-            $this.resetTimeout();
+            setTimeout(function () {
+                $this.checkHidden();
+            }, 1000);
         });
+        this.checkHidden();
     },
 
     toggleInterface: function () {
         console.log('toogle interface; current : ' + this.interfaceVisible);
-        if (this.interfaceVisible) {
+        if (this.interfaceVisible && this.autoHideArrows()) {
             return this.hideInterface();
         } else {
             return this.displayInterface();
@@ -83,6 +104,9 @@ FluidbookInterface.prototype = {
         }, this.visibleTime);
     },
     hideInterface: function () {
+        if (!this.autoHideArrows()) {
+            return;
+        }
         this.interfaceVisible = false;
         if ($("#helpView").is(':visible') || document.activeElement.tagName.toLowerCase() === 'input') {
             this.resetTimeout();
index 7026d9e1102802ab757201d3f12b388861f9c563..8c1d2ea909ac8b313181068b85030e27a5cc740b 100644 (file)
@@ -20,7 +20,7 @@ function FluidbookResize(fluidbook) {
 
 FluidbookResize.prototype = {
     reduceHorizontalMargins: function () {
-        return this.orientation == 'portrait';//&& this.fluidbook.support.isMobile /*&& Modernizr.touch*/;
+        return this.orientation == 'portrait' && this.fluidbook.support.isMobile && Modernizr.touch;
     },
 
     setMargins: function () {
@@ -323,7 +323,17 @@ FluidbookResize.prototype = {
             this.fluidbook.zoom.resetZoom();
             this.fluidbook.pageTransition();
             $(this.fluidbook).trigger('fluidbook.resize.orientation', {orientation: this.orientation});
+            if (this.fluidbook.support.android) {
+                setTimeout(function () {
+                    $($this.fluidbook).trigger('fluidbook.resize.orientation', {orientation: $this.orientation});
+                }, 1000);
+                setTimeout(function () {
+                    $($this.fluidbook).trigger('fluidbook.resize.orientation', {orientation: $this.orientation});
+                }, 2000);
+            }
         }
+
+
     },
     getScreenFluidbookWidth: function () {
         return $("#fluidbook").outerWidth() * fluidbook.resize.bookScale;
@@ -334,11 +344,12 @@ FluidbookResize.prototype = {
         }
         if (!this.fluidbook.nav.menuIsOpen) return false;
 
-        var wh = $(window).height(),
-            formHeight = $('#searchForm').height();
-        marginTop = marginBottom = Math.min(Math.round(wh * 0.075), 50); // Relative margins with a max of 50
-        searchResultsMaxHeight = wh - formHeight - marginTop - marginBottom,
-            mainMenuMaxHeight = wh - $('#menuSearch').height() - $('#shareLinks').outerHeight();
+        var wh = $(window).height();
+        var formHeight = $('#searchForm').height();
+        var marginBottom;
+        var marginTop = marginBottom = Math.min(Math.round(wh * 0.075), 50); // Relative margins with a max of 50
+        var searchResultsMaxHeight = wh - formHeight - marginTop - marginBottom;
+        var mainMenuMaxHeight = wh - $('#menuSearch').height() - $('#shareLinks').outerHeight();
 
         // Search results element may not exist when resize is called
         if (this.fluidbook.search.menuSearchResults == undefined) {