summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2016-12-01 21:00:37 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-03-27 01:15:36 +0000
commit458045bb43a31b02443459e053c18ed95d134d7a (patch)
tree2fee77dc53becca9171051db38c3c31eb712288f
parent5bc5fedb20909bcdfed1fe44904fc392404b3bdb (diff)
tdf#106597 loleaflet - calc: horizontal scrollbar not updated on doc width change
Change-Id: I268ab65d0bf7a6794028e23e51012c11534d6f2f Reviewed-on: https://gerrit.libreoffice.org/35347 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--loleaflet/src/control/Control.Scroll.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 313144081..40089a999 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -118,14 +118,25 @@ L.Control.Scroll = L.Control.extend({
},
_onUpdateSize: function (e) {
+ // we need to avoid precision issues in comparison (in the end values are pixels)
+ var prevDocWidth = Math.ceil(parseFloat(L.DomUtil.getStyle(this._mockDoc, 'width')));
+ var prevDocHeight = Math.ceil(parseFloat(L.DomUtil.getStyle(this._mockDoc, 'height')));
+ var newDocWidth = Math.ceil(e.x);
+ var newDocHeight = Math.ceil(e.y);
// for writer documents, ignore scroll while document size is being reduced
- var prevDocY = parseFloat(L.DomUtil.getStyle(this._mockDoc, 'height'));
- if (this._map.getDocType() === 'text' && e.y < prevDocY) {
+ if (this._map.getDocType() === 'text' && newDocHeight < prevDocHeight) {
this._ignoreScroll = true;
}
L.DomUtil.setStyle(this._mockDoc, 'width', e.x + 'px');
L.DomUtil.setStyle(this._mockDoc, 'height', e.y + 'px');
+
+ // custom scrollbar plugin checks automatically for content height changes but not for content width changes
+ // so we need to update scrollbars explicitly; moreover we want to avoid to have 'update' invoked twice
+ // in case prevDocHeight !== newDocHeight
+ if (prevDocWidth !== newDocWidth && prevDocHeight === newDocHeight) {
+ $('.scroll-container').mCustomScrollbar('update');
+ }
},
_onUpdateScrollOffset: function (e) {