[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - loleaflet/js loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Apr 16 07:10:23 UTC 2019


 loleaflet/js/jquery.mCustomScrollbar.js |   27 +++++++++++++++++++--------
 loleaflet/src/control/Control.Scroll.js |    5 ++++-
 2 files changed, 23 insertions(+), 9 deletions(-)

New commits:
commit 42a739a7bc53f9992056de4e00db90a5e613c04c
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Apr 11 13:32:24 2019 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Apr 16 09:10:06 2019 +0200

    Prevent view from jumping on zoom in/out on mobile
    
    Change-Id: I29262d518d61a4a06d66271033c958e56ff16a2b
    Reviewed-on: https://gerrit.libreoffice.org/70592
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js
index e242263e2..abaa9b9e0 100644
--- a/loleaflet/js/jquery.mCustomScrollbar.js
+++ b/loleaflet/js/jquery.mCustomScrollbar.js
@@ -284,6 +284,11 @@ and dependencies (minified).
 				*/
 				updateOnContentResize:true,
 				/*
+				prevent from updating view position after content resize to avoid jumping on mobile devices
+				values: boolean
+				*/
+				jumpOnContentResize:true,
+				/*
 				auto-update scrollbars each time each image inside the element is fully loaded 
 				values: "auto", boolean
 				*/
@@ -561,31 +566,37 @@ and dependencies (minified).
 						var to=[Math.abs(mCSB_container[0].offsetTop),Math.abs(mCSB_container[0].offsetLeft)];
 						if(o.axis!=="x"){ /* y/yx axis */
 							if(!d.overflowed[0]){ /* y scrolling is not required */
-								_resetContentPosition.call(this); /* reset content position */
+								if(o.advanced.jumpOnContentResize)
+									_resetContentPosition.call(this); /* reset content position */
 								if(o.axis==="y"){
 									_unbindEvents.call(this);
-								}else if(o.axis==="yx" && d.overflowed[1]){
+								}else if(o.axis==="yx" && d.overflowed[1] && o.advanced.jumpOnContentResize){
 									_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
 								}
-							}else if(mCSB_dragger[0].height()>mCSB_dragger[0].parent().height()){
+							}else if(mCSB_dragger[0].height()>mCSB_dragger[0].parent().height()
+									&& o.advanced.jumpOnContentResize){
 								_resetContentPosition.call(this); /* reset content position */
 							}else{ /* y scrolling is required */
-								_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
+								if(o.advanced.jumpOnContentResize)
+									_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
 								d.contentReset.y=null;
 							}
 						}
 						if(o.axis!=="y"){ /* x/yx axis */
 							if(!d.overflowed[1]){ /* x scrolling is not required */
-								_resetContentPosition.call(this); /* reset content position */
+								if(o.advanced.jumpOnContentResize)
+									_resetContentPosition.call(this); /* reset content position */
 								if(o.axis==="x"){
 									_unbindEvents.call(this);
-								}else if(o.axis==="yx" && d.overflowed[0]){
+								}else if(o.axis==="yx" && d.overflowed[0] && o.advanced.jumpOnContentResize){
 									_scrollTo($this,to[0].toString(),{dir:"y",dur:0,overwrite:"none"});
 								}
 							}else if(mCSB_dragger[1].width()>mCSB_dragger[1].parent().width()){
-								_resetContentPosition.call(this); /* reset content position */
+								if(o.advanced.jumpOnContentResize)
+									_resetContentPosition.call(this); /* reset content position */
 							}else{ /* x scrolling is required */
-								_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
+								if(o.advanced.jumpOnContentResize)
+									_scrollTo($this,to[1].toString(),{dir:"x",dur:0,overwrite:"none"});
 								d.contentReset.x=null;
 							}
 						}
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 829ce18ab..ab3fc47c6 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -31,7 +31,10 @@ L.Control.Scroll = L.Control.extend({
 			axis: 'yx',
 			theme: 'minimal-dark',
 			scrollInertia: 0,
-			advanced:{autoExpandHorizontalScroll: true}, /* weird bug, it should be false */
+			advanced:{
+				autoExpandHorizontalScroll: true, /* weird bug, it should be false */
+				jumpOnContentResize: false /* prevent from jumping on a mobile devices */
+			},
 			callbacks:{
 				onScrollStart: function() {
 					control._map.fire('closepopup');


More information about the Libreoffice-commits mailing list