From 5ec739e614f5145c2fc3d04364a33240a3bab436 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 14 Dec 2017 19:09:39 +0100 Subject: [PATCH] fix #1710 @1.5 --- js/libs/fluidbook/fluidbook.interface.js | 30 +++++++++++++++++++++--- js/libs/fluidbook/fluidbook.resize.js | 23 +++++++++++++----- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.interface.js b/js/libs/fluidbook/fluidbook.interface.js index fc46c8a6..8833ab36 100644 --- a/js/libs/fluidbook/fluidbook.interface.js +++ b/js/libs/fluidbook/fluidbook.interface.js @@ -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(); diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index 7026d9e1..8c1d2ea9 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -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) { -- 2.39.5