loleaflet/src/control/Control.Scroll.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
New commits: commit e7822bb452ea985096c325ff73c8f59be18d70d2 Author: Marco Cecchetti <marco.cecche...@collabora.com> Date: Thu Dec 1 21:00:37 2016 +0100 loleaflet - calc: horizontal scrollbar not updated on doc width change Change-Id: I268ab65d0bf7a6794028e23e51012c11534d6f2f Reviewed-on: https://gerrit.libreoffice.org/31543 Reviewed-by: pranavk <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js index 3131440..40089a9 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) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits