From d14d6ccbbb52e21be136569ec6aa422db7932efb Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 9 Jun 2017 11:41:51 +0200 Subject: [PATCH] wip #1445 @1 --- js/libs/fluidbook/fluidbook.resize.js | 3 ++ js/libs/fluidbook/fluidbook.slider.js | 45 ++++++++++++++++++--------- style/fluidbook.less | 1 + 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.resize.js b/js/libs/fluidbook/fluidbook.resize.js index ea21e1e2..c97847d7 100644 --- a/js/libs/fluidbook/fluidbook.resize.js +++ b/js/libs/fluidbook/fluidbook.resize.js @@ -274,5 +274,8 @@ FluidbookResize.prototype = { this.fluidbook.zoom.resetZoom(); this.fluidbook.pageTransition(); } + }, + getScreenFluidbookWidth:function(){ + return $("#fluidbook").outerWidth()*fluidbook.resize.bookScale; } }; \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.slider.js b/js/libs/fluidbook/fluidbook.slider.js index 458c99b4..67e61ff0 100644 --- a/js/libs/fluidbook/fluidbook.slider.js +++ b/js/libs/fluidbook/fluidbook.slider.js @@ -16,17 +16,26 @@ FluidbookSlider.prototype = { }); $("#sliderback").on('click', function (e) { + if ($this.fluidbook.transitionning) { + return; + } var left = e.pageX - $(this).offset().left; - $this.updatePageByCursorPosition(left); + $this.updatePageByCursorPosition(left, true); }); }, - updatePageByCursorPosition: function (pos) { - var snap = Math.floor(pos / this.snapsWidth); - if (this.fluidbook.orientation == 'portrait') { - this.fluidbook.setCurrentPage(snap); - } else { - this.fluidbook.setCurrentPage(snap * 2); + updatePageByCursorPosition: function (pos, updateCursor) { + if (updateCursor == undefined) { + updateCursor = false; + } + + var page = Math.floor(pos / this.snapsWidth); + if (this.fluidbook.orientation != 'portrait') { + page *= 2; + } + this.fluidbook.setCurrentPage(page); + if (updateCursor) { + this.updateCursorPosition(page); } return false; }, @@ -36,10 +45,15 @@ FluidbookSlider.prototype = { if (single) { this.sliderWidth = ww / 2; } else { - this.sliderWidth = ww / 3; + this.sliderWidth = this.fluidbook.resize.getScreenFluidbookWidth() * 0.4; } this.sliderWidth = Math.round(this.sliderWidth); - $("#slider").css({width: this.sliderWidth, left: (ww - this.sliderWidth) / 2, top: hh - 32}); + var bottom = 26; + if (single) { + bottom = 18; + } + + $("#slider").css({width: this.sliderWidth, left: (ww - this.sliderWidth) / 2, top: hh - bottom}); this.updateSnaps(single); this.cursorWidth = Math.max(30, this.snapsWidth); $("#slidercursor").css('width', this.cursorWidth); @@ -61,19 +75,20 @@ FluidbookSlider.prototype = { this.snapsWidth = this.sliderWidth / this.snapsCount; }, - updateCursorPosition: function () { - + updateCursorPosition: function (page) { + if (page == undefined) { + page = this.fluidbook.currentPage; + } var left; if (this.fluidbook.resize.orientation == 'portrait') { - left = this.snapsWidth * (Math.max(1, this.fluidbook.currentPage) - 1); + left = this.snapsWidth * (Math.max(1, page) - 1); } else { - var current = this.fluidbook.currentPage; - if (current % 2 == 1 && this.fluidbook.currentPage != this.fluidbook.datas.pages) { + var current = page; + if (current % 2 == 1 && page != this.fluidbook.datas.pages) { current--; } left = this.snapsWidth * (current / 2); } - $("#slidercursor").css('left', left); } }; \ No newline at end of file diff --git a/style/fluidbook.less b/style/fluidbook.less index d24f1505..05fadc1c 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -392,6 +392,7 @@ body, html { padding: 0; position: absolute; white-space: nowrap; + pointer-events: none; } #pagesnumbers div { -- 2.39.5