From cceb2e25146dc7d22cacea236a942234019d531e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 1 Apr 2022 17:52:28 +0200 Subject: [PATCH] wip #5158 @2 --- js/libs/fluidbook/fluidbook.desktop.js | 11 +++-- js/libs/fluidbook/fluidbook.nav.js | 12 +----- js/libs/fluidbook/fluidbook.zoom.js | 56 +++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.desktop.js b/js/libs/fluidbook/fluidbook.desktop.js index 178dac75..77bb4c25 100644 --- a/js/libs/fluidbook/fluidbook.desktop.js +++ b/js/libs/fluidbook/fluidbook.desktop.js @@ -16,7 +16,12 @@ FluidbookDesktop.prototype = { } }); $(document).on('click', '#links', function (e) { - if ($this.fluidbook.zoom.enabled && $this.fluidbook.input.isUsingMouse() && !$this.fluidbook.hasDraggableOnPage()) { + if ( + $this.fluidbook.settings.clickZoom && + $this.fluidbook.zoom.enabled && + $this.fluidbook.input.isUsingMouse() && + !$this.fluidbook.hasDraggableOnPage() + ) { $this.clickZoom(e); return false; } @@ -27,7 +32,7 @@ FluidbookDesktop.prototype = { $(document).on('mousemove', 'body', function (e) { - if ($this.fluidbook.zoom.enabled) { + if ($this.fluidbook.zoom.enabled && $this.fluidbook.settings.zoomMouseMoveMode === 'move') { $this.moveZoom(e); } }); @@ -56,7 +61,7 @@ FluidbookDesktop.prototype = { } else if (way == -1) { newScale = 1; } - this.moveZoom(e, true) + this.moveZoom(e, true); this.fluidbook.zoom.setZoom(newScale); return false; }, diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index b2e786b8..4203ab68 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -464,6 +464,7 @@ FluidbookNav.prototype = { // __('zoom out') link = this.addLink(navType, 'nav-zoomin', '#', 'zoomin', 'zoom in', 'zoom in'); link = this.addLink(navType, 'nav-zoomout', '#', 'zoomout', 'zoom out', 'zoom out'); + } else if (icon === 'fullscreen' && this.fluidbook.settings.fullscreen && this.fluidbook.support.fullscreen && !this.fluidbook.settings.phonegap) { // __('switch between fullscreen and normal') link = this.addLink(navType, 'nav-' + icon, '#', icon, 'full screen', 'switch between fullscreen and normal', 'F11'); @@ -731,17 +732,6 @@ FluidbookNav.prototype = { } }); - // Zoom In icon - $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomin', function (e) { - $this.fluidbook.desktop.clickZoom(e, 'in'); - return false; - }); - - // Zoom Out icon - $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomout', function (e) { - $this.fluidbook.desktop.clickZoom(e, 'out'); - return false; - }); if (this.fluidbook.support.fullscreen) { this.initFullScreen(); diff --git a/js/libs/fluidbook/fluidbook.zoom.js b/js/libs/fluidbook/fluidbook.zoom.js index 341841f0..2eaad2b4 100644 --- a/js/libs/fluidbook/fluidbook.zoom.js +++ b/js/libs/fluidbook/fluidbook.zoom.js @@ -2,6 +2,7 @@ function FluidbookZoom(fluidbook) { this.fluidbook = fluidbook; this.zoom = 0; this.originpct = [0.5, 0.5]; + this.zoomStep = 0.7; this.originpx = ['0px', '0px']; this.initial = this.fluidbook.settings.zoom / 100; this.max = this.fluidbook.settings.zoomw / 100; @@ -14,16 +15,35 @@ function FluidbookZoom(fluidbook) { FluidbookZoom.prototype = { init: function () { - if (this.fluidbook.mobilefirst.enabled) { + if (this.fluidbook.mobilefirst.enabled || (this.fluidbook.settings.zoom <= 100 && this.fluidbook.settings.zoomw <= 100)) { this.disable(); return; } + if (!this.fluidbook.settings.clickZoom) { + this.disableZoomCursor(); + } var $this = this; this.setTransition(true); this.initMouseWheel(); + // Zoom icon + $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomin', function (e) { + if ($this.fluidbook.settings.zoomMouseMoveMode !== 'dragndrop') { + $this.fluidbook.desktop.moveZoom(e, true); + } else { + $this.fluidbook.zoom.setOriginPct(0.5, 0.5, true); + } + $this.fluidbook.zoom.zoomInFromMenu(); + + return false; + }); + $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomout', function (e) { + $this.fluidbook.zoom.zoomOutFromMenu(); + return false; + }); + $(this.fluidbook).on('fluidbook.zoom.out.end', function () { $("#z").addClass('nozoom'); }); @@ -74,10 +94,10 @@ FluidbookZoom.prototype = { wheelZoom: function (delta) { var dir; if (delta > 0) { - delta = 0.7; + delta = this.zoomStep; dir = 1; } else { - delta = -0.7; + delta = -1 * this.zoomStep; dir = -1; } this.setZoom(this.zoom + delta, dir); @@ -121,7 +141,11 @@ FluidbookZoom.prototype = { }, disable: function () { + this.disableZoomCursor(); this.enabled = false; + }, + + disableZoomCursor: function () { $('body').addClass('zoom-disabled'); }, @@ -138,6 +162,7 @@ FluidbookZoom.prototype = { setZoom: function (zoom, direction, end) { + console.log('set zoom ', zoom); var origZoom = this.zoom; if (end === undefined) { @@ -180,6 +205,22 @@ FluidbookZoom.prototype = { } }, + zoomInFromMenu: function () { + if (this.zoom === 1) { + this.setZoom(this.fluidbook.settings.zoom / 100); + } else { + this.setZoom(this.zoom + this.zoomStep); + } + }, + + zoomOutFromMenu: function () { + var z = this.zoom - this.zoomStep; + if (z < 1 + this.zoomStep) { + z = 1; + } + this.setZoom(z); + }, + setTransition: function (transition) { if (transition == undefined) { transition = true; @@ -281,7 +322,12 @@ FluidbookZoom.prototype = { // When the search results nav is active, don't reveal interface elements when zooming out... if (!this.fluidbook.search.resultsNavActive()) { - var hiddenElements = $("header,footer,#interface,#links a.bookmark"); + var selector = 'footer,#interface,#links a.bookmark'; + if (this.fluidbook.settings.hideHeaderOnZoom) { + selector += ',header'; + } + var hiddenElements = $(selector); + if (this.zoom !== 1) { if (this.fluidbook.help !== undefined) { @@ -318,7 +364,7 @@ FluidbookZoom.prototype = { } try { this.fluidbook.loader.renderTextsCanvas(); - }catch (e){ + } catch (e) { } -- 2.39.5