[Libreoffice-commits] online.git: 7 commits - loleaflet/build loleaflet/debug loleaflet/dist loleaflet/README loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Fri Jul 24 06:10:49 PDT 2015
loleaflet/README | 26 +++++
loleaflet/build/deps.js | 22 +++-
loleaflet/debug/document/document_simple_example.html | 27 -----
loleaflet/dist/leaflet.css | 4
loleaflet/src/control/Control.Scroll.js | 93 ++++++++++++++++++
loleaflet/src/control/Scroll.js | 19 +++
loleaflet/src/layer/tile/GridLayer.js | 50 +--------
loleaflet/src/layer/tile/TileLayer.js | 8 -
loleaflet/src/map/Map.js | 20 ---
loleaflet/src/map/handler/Map.Scroll.js | 59 +++++++++++
loleaflet/src/map/handler/Map.ScrollWheelZoom.js | 68 -------------
11 files changed, 235 insertions(+), 161 deletions(-)
New commits:
commit eca15f7c173ceffedf8317ef1325dae9bf1e3b0d
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 16:04:28 2015 +0300
loleaflet: scroll API and event description in README
diff --git a/loleaflet/README b/loleaflet/README
index 6a5729c..c91c0d4 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -109,6 +109,32 @@ Save:
- API:
map.saveAs(url, [format, options])
+Scroll (the following are measured in pixels):
+ - API:
+ map.scroll(x,y)
+ + scroll right by 'x' and down by 'y' (or left and up if negative)
+ map.scrollDown(y)
+ + scroll down by 'y' (or up if negative)
+ map.scrollRight(x)
+ + scroll right by 'x' (or left if nevative)
+ - events
+ map.on('docsize', function (e) {}) where:
+ + e.x = document width
+ + e.y = document height
+ map.on('updatescrolloffset', function (e) {}) where:
+ + e.x = difference between document's left and current view's left
+ (how much has the document been scrolled right)
+ + e.y = difference between document's top and current view's top
+ (how much has the document been scrolled down)
+ - this event is fired when zooming and the current view is maintained but the
+ document shrinks or grow OR when the document is panned OR when the container is resized
+ map.on('scrollto', function (e) {}) where:
+ + e.x = view's left position (so that the cursor/search result is in the center)
+ + e.y = view's top position (so that the cursor/search result is in the center)
+ map.on('scrollby', function (e) {}) where:
+ + e.x = the amount scrolled to the right (or left if negative)
+ + e.y = the amount scrolled to the bottom (or top if negative)
+
Contributing
------------
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 9b3091c..2974882 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -306,6 +306,11 @@ var deps = {
desc: 'Parts change handler.'
},
+ Scroll: {
+ src: ['control/Scroll.js'],
+ desc: 'Scroll handler.'
+ },
+
AnimationPan: {
src: [
'dom/DomEvent.js',
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 0755de6..5cb1a81 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -49,7 +49,7 @@ L.Control.Scroll = L.Control.extend({
if (!offset.equals(new L.Point(0, 0))) {
this._prevScrollY = -e.mcs.top;
this._prevScrollX = -e.mcs.left;
- this._map.panBy(offset, {animate:false});
+ this._map.scroll(offset.x, offset.y);
}
},
diff --git a/loleaflet/src/control/Scroll.js b/loleaflet/src/control/Scroll.js
new file mode 100644
index 0000000..ba0b2de
--- /dev/null
+++ b/loleaflet/src/control/Scroll.js
@@ -0,0 +1,19 @@
+/*
+ * Scroll methods
+ */
+L.Map.include({
+ scroll: function (x, y) {
+ if (typeof (x) !== 'number' || typeof (y) !== 'number') {
+ return;
+ }
+ this.panBy(new L.Point(x, y), {animate: false});
+ },
+
+ scrollDown: function (y) {
+ this.scroll(0, y);
+ },
+
+ scrollRight: function (x) {
+ this.scroll(x, 0);
+ }
+});
commit 36ccbd84fb94e98829ae533663b6e5263ffa6957
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 15:44:02 2015 +0300
loleaflet: scroll by 1/4 of the view size
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index 9814ffb..fac8cbf 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -4,9 +4,7 @@
L.Map.mergeOptions({
scroll: true,
- wheelDebounceTime: 40,
- // scroll by 150px
- scrollAmount: 150
+ wheelDebounceTime: 40
});
L.Map.Scroll = L.Handler.extend({
@@ -47,13 +45,14 @@ L.Map.Scroll = L.Handler.extend({
_performScroll: function () {
var map = this._map,
- delta = -this._delta;
+ delta = -this._delta,
+ scrollAmount = Math.round(map.getSize().y / 4);
this._delta = 0;
this._startTime = null;
if (!delta) { return; }
- map.fire('scrollby', {x: 0, y: delta * this._map.options.scrollAmount});
+ map.fire('scrollby', {x: 0, y: delta * scrollAmount});
}
});
commit d7019a0a79b4f43fe3683e164d52140145f59a53
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 15:40:58 2015 +0300
loleaflet: reverse mouse wheel delta sign
So that a positive value would scroll down
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index f086109..0755de6 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -64,6 +64,7 @@ L.Control.Scroll = L.Control.extend({
},
_onScrollBy: function (e) {
+ e.y *= (-1);
var y = '+=' + e.y;
if (e.y < 0) {
y = '-=' + Math.abs(e.y);
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index 141bf61..9814ffb 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -47,7 +47,7 @@ L.Map.Scroll = L.Handler.extend({
_performScroll: function () {
var map = this._map,
- delta = this._delta;
+ delta = -this._delta;
this._delta = 0;
this._startTime = null;
commit bfa5eda5036062eecf4191bf79dd3d75dfefab34
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 15:10:08 2015 +0300
loleaflet: renamed handler so we can later have a 'scroll' method
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index 46edf12..141bf61 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -57,4 +57,4 @@ L.Map.Scroll = L.Handler.extend({
}
});
-L.Map.addInitHook('addHandler', 'scroll', L.Map.Scroll);
+L.Map.addInitHook('addHandler', 'scrollHandler', L.Map.Scroll);
commit e7fc840c9e89eb8e7c6430183c1302bf6682417e
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 12:52:05 2015 +0300
loleaflet: mouse scroll is now triggered on the map div
Not on the document scrollbar container as before
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
index 2e72a75..f086109 100644
--- a/loleaflet/src/control/Control.Scroll.js
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -10,6 +10,7 @@ L.Control.Scroll = L.Control.extend({
this._mockDoc.id = 'mock-doc';
map.on('scrollto', this._onScrollTo, this);
+ map.on('scrollby', this._onScrollBy, this);
map.on('docsize', this._onUpdateSize, this);
map.on('updatescrolloffset', this._onUpdateScrollOffset, this);
@@ -59,7 +60,15 @@ L.Control.Scroll = L.Control.extend({
_onScrollTo: function (e) {
// triggered by the document (e.g. search result out of the viewing area)
- $('#scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x]);
+ $('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x]);
+ },
+
+ _onScrollBy: function (e) {
+ var y = '+=' + e.y;
+ if (e.y < 0) {
+ y = '-=' + Math.abs(e.y);
+ }
+ $('.scroll-container').mCustomScrollbar('scrollTo', [y, '+=0']);
},
_onUpdateSize: function (e) {
@@ -71,10 +80,10 @@ L.Control.Scroll = L.Control.extend({
_onUpdateScrollOffset: function (e) {
this._ignoreScroll = null;
- $('#scroll-container').mCustomScrollbar('stop');
+ $('.scroll-container').mCustomScrollbar('stop');
this._prevScrollY = e.y;
this._prevScrollX = e.x;
- $('#scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x], {callbacks: false, timeout:0});
+ $('.scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x], {callbacks: false, timeout:0});
}
});
diff --git a/loleaflet/src/map/handler/Map.Scroll.js b/loleaflet/src/map/handler/Map.Scroll.js
index 24fd4df..46edf12 100644
--- a/loleaflet/src/map/handler/Map.Scroll.js
+++ b/loleaflet/src/map/handler/Map.Scroll.js
@@ -1,13 +1,15 @@
/*
- * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.
+ * L.Handler.Scroll is used by L.Map to enable mouse scroll wheel zoom on the map.
*/
L.Map.mergeOptions({
- scrollWheelZoom: true,
- wheelDebounceTime: 40
+ scroll: true,
+ wheelDebounceTime: 40,
+ // scroll by 150px
+ scrollAmount: 150
});
-L.Map.ScrollWheelZoom = L.Handler.extend({
+L.Map.Scroll = L.Handler.extend({
addHooks: function () {
L.DomEvent.on(this._map._container, {
mousewheel: this._onWheelScroll,
@@ -38,31 +40,21 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
var left = Math.max(debounce - (+new Date() - this._startTime), 0);
clearTimeout(this._timer);
- this._timer = setTimeout(L.bind(this._performZoom, this), left);
+ this._timer = setTimeout(L.bind(this._performScroll, this), left);
L.DomEvent.stop(e);
},
- _performZoom: function () {
+ _performScroll: function () {
var map = this._map,
- delta = this._delta,
- zoom = map.getZoom();
-
- map.stop(); // stop panning and fly animations if any
-
- delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta);
- delta = Math.max(Math.min(delta, 4), -4);
- delta = map._limitZoom(zoom + delta) - zoom;
+ delta = this._delta;
this._delta = 0;
this._startTime = null;
if (!delta) { return; }
-
- if (map.options.scrollWheelZoom === 'center') {
- map.setZoom(zoom + delta);
- } else {
- map.setZoomAround(this._lastMousePos, zoom + delta);
- }
+ map.fire('scrollby', {x: 0, y: delta * this._map.options.scrollAmount});
}
});
+
+L.Map.addInitHook('addHandler', 'scroll', L.Map.Scroll);
commit d33f71d32d1cef48fdee63ee0d6c5c1f4d9d048c
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 12:04:18 2015 +0300
loleaflet: renamed Map.ScrollWheelZoom to Map.Scroll
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index f4b8cd4..9b3091c 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -166,11 +166,17 @@ var deps = {
heading: 'Interaction'
},
+ MapScroll: {
+ src: ['dom/DomEvent.js',
+ 'core/Handler.js',
+ 'map/handler/Map.Scroll.js'],
+ desc: 'Handles the mouse wheel scroll',
+ },
+
MouseZoom: {
src: ['dom/DomEvent.js',
'core/Handler.js',
- 'map/handler/Map.DoubleClickZoom.js',
- 'map/handler/Map.ScrollWheelZoom.js'],
+ 'map/handler/Map.DoubleClickZoom.js'],
desc: 'Scroll wheel zoom and double click zoom on the map.'
},
diff --git a/loleaflet/src/map/handler/Map.ScrollWheelZoom.js b/loleaflet/src/map/handler/Map.Scroll.js
similarity index 100%
rename from loleaflet/src/map/handler/Map.ScrollWheelZoom.js
rename to loleaflet/src/map/handler/Map.Scroll.js
commit 9b097f376d6d339c0a77587b4fab75ba6482f06f
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Jul 24 11:30:32 2015 +0300
loleaflet: add the scrollbars as a control to be easily removed
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index a3d0ee9..f4b8cd4 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -255,6 +255,13 @@ var deps = {
desc: 'Display document loading status'
},
+ ControlScroll: {
+ src: ['control/Control.js',
+ 'control/Control.Scroll.js'],
+ heading: 'Controls',
+ desc: 'Creates and handles the scrollbar'
+ },
+
ControlAttrib: {
src: ['control/Control.js',
'control/Control.Attribution.js'],
diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index 2df9c91..551137b 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -38,10 +38,6 @@
</div>
<div id="document-container" style="top:100px">
<div id="map"></div>
- <div id="scroll-container">
- <div id="mock-document">
- </div>
- </div>
</div>
<div id="spreadsheet-tab" class="spreadsheet-tab">
</div>
@@ -65,7 +61,7 @@
vex.dialog.alert('Wrong host, usage: host=ws://localhost:9980');
}
- var map = L.map('map', 'scroll-container', 'mock-document', {
+ var map = L.map('map', {
center: [0, 0],
zoom: 10,
minZoom: 1,
@@ -82,6 +78,7 @@
map.addControl(L.control.zoom());
map.addControl(L.control.parts());
map.addControl(L.control.statusIndicator());
+ map.addControl(L.control.scroll());
////// Document layer ////
var docLayer = new L.TileLayer('', {
@@ -91,25 +88,5 @@
readOnly: false
});
map.addLayer(docLayer);
-
- ////// Scrollbar /////
- (function($){
- $(window).load(function(){
- $("#scroll-container").mCustomScrollbar({
- axis: 'yx',
- theme: 'dark-thick',
- scrollInertia: 0,
- callbacks:{
- onScroll: function(){
- docLayer._onScrollEnd(this);
- },
- whileScrolling: function(){
- docLayer._onScroll(this);
- },
- alwaysTriggerOffsets:false
- }
- });
- });
- })(jQuery);
</script>
</body></html>
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index d866d45..b577273 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -553,7 +553,7 @@ a.leaflet-control-buttons:hover {
}
#map
-#scroll-container {
+.scroll-container {
position: absolute;
left: 0;
top: 0;
@@ -561,7 +561,7 @@ a.leaflet-control-buttons:hover {
bottom: 0;
}
-#scroll-container {
+.scroll-container {
height: 100%;
width: 100%;
overflow: auto;
diff --git a/loleaflet/src/control/Control.Scroll.js b/loleaflet/src/control/Control.Scroll.js
new file mode 100644
index 0000000..2e72a75
--- /dev/null
+++ b/loleaflet/src/control/Control.Scroll.js
@@ -0,0 +1,83 @@
+/*
+ * L.Control.Scroll handles scrollbars
+ */
+
+L.Control.Scroll = L.Control.extend({
+
+ onAdd: function (map) {
+ this._scrollContainer = L.DomUtil.create('div', 'scroll-container', map._container.parentElement);
+ this._mockDoc = L.DomUtil.create('div', '', this._scrollContainer);
+ this._mockDoc.id = 'mock-doc';
+
+ map.on('scrollto', this._onScrollTo, this);
+ map.on('docsize', this._onUpdateSize, this);
+ map.on('updatescrolloffset', this._onUpdateScrollOffset, this);
+
+ var control = this;
+ $(".scroll-container").mCustomScrollbar({
+ axis: 'yx',
+ theme: 'dark-thick',
+ scrollInertia: 0,
+ callbacks:{
+ onScroll: function() {
+ control._onScrollEnd(this);
+ },
+ whileScrolling: function() {
+ control._onScroll(this);
+ },
+ alwaysTriggerOffsets: false
+ }
+ });
+ return document.createElement('div');
+ },
+
+ _onScroll: function (e) {
+ if (this._ignoreScroll) {
+ return;
+ }
+ if (this._prevScrollY === undefined) {
+ this._prevScrollY = 0;
+ }
+ if (this._prevScrollX === undefined) {
+ this._prevScrollX = 0;
+ }
+ var offset = new L.Point(
+ -e.mcs.left - this._prevScrollX,
+ -e.mcs.top - this._prevScrollY);
+
+ if (!offset.equals(new L.Point(0, 0))) {
+ this._prevScrollY = -e.mcs.top;
+ this._prevScrollX = -e.mcs.left;
+ this._map.panBy(offset, {animate:false});
+ }
+ },
+
+ _onScrollEnd: function (e) {
+ this._prevScrollY = -e.mcs.top;
+ this._prevScrollX = -e.mcs.left;
+ },
+
+ _onScrollTo: function (e) {
+ // triggered by the document (e.g. search result out of the viewing area)
+ $('#scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x]);
+ },
+
+ _onUpdateSize: function (e) {
+ this._ignoreScroll = true;
+ setTimeout(L.bind(function() {this._ignoreScroll = null;}, this), 200);
+ L.DomUtil.setStyle(this._mockDoc, 'width', e.x + 'px');
+ L.DomUtil.setStyle(this._mockDoc, 'height', e.y + 'px');
+ },
+
+ _onUpdateScrollOffset: function (e) {
+ this._ignoreScroll = null;
+ $('#scroll-container').mCustomScrollbar('stop');
+ this._prevScrollY = e.y;
+ this._prevScrollX = e.x;
+ $('#scroll-container').mCustomScrollbar('scrollTo', [e.y, e.x], {callbacks: false, timeout:0});
+ }
+});
+
+L.control.scroll = function (options) {
+ return new L.Control.Scroll(options);
+};
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 4596868..515964f 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -382,27 +382,15 @@ L.GridLayer = L.Layer.extend({
var scrollPixelLimits = new L.Point(this._docWidthTwips / this._tileWidthTwips,
this._docHeightTwips / this._tileHeightTwips);
scrollPixelLimits = scrollPixelLimits.multiplyBy(this._tileSize);
-
- if (!sizeChanged) {
- this._ignoreScroll = true;
- setTimeout(L.bind(function() {this._ignoreScroll = null;}, this), 200);
- }
- L.DomUtil.setStyle(this._map._mockDoc, 'width', scrollPixelLimits.x + 'px');
- L.DomUtil.setStyle(this._map._mockDoc, 'height', scrollPixelLimits.y + 'px');
+ this._map.fire('docsize', {x: scrollPixelLimits.x, y: scrollPixelLimits.y});
},
_updateScrollOffset: function () {
- this._ignoreScroll = null;
- if (this._map._scrollContainer.mcs) {
- $('#scroll-container').mCustomScrollbar('stop');
- var centerPixel = this._map.project(this._map.getCenter());
- var newScrollPos = centerPixel.subtract(this._map.getSize().divideBy(2));
- var x = newScrollPos.x < 0 ? 0 : newScrollPos.x;
- var y = newScrollPos.y < 0 ? 0 : newScrollPos.y;
- this._prevScrollY = y;
- this._prevScrollX = x;
- $('#scroll-container').mCustomScrollbar('scrollTo', [y, x], {callbacks: false, timeout:0});
- }
+ var centerPixel = this._map.project(this._map.getCenter());
+ var newScrollPos = centerPixel.subtract(this._map.getSize().divideBy(2));
+ var x = newScrollPos.x < 0 ? 0 : newScrollPos.x;
+ var y = newScrollPos.y < 0 ? 0 : newScrollPos.y;
+ this._map.fire('updatescrolloffset', {x: x, y: y});
},
_setZoomTransforms: function (center, zoom) {
@@ -762,32 +750,6 @@ L.GridLayer = L.Layer.extend({
return true;
},
- _onScroll: function (evt) {
- if (this._ignoreScroll) {
- return;
- }
- if (this._prevScrollY === undefined) {
- this._prevScrollY = 0;
- }
- if (this._prevScrollX === undefined) {
- this._prevScrollX = 0;
- }
- var offset = new L.Point(
- -evt.mcs.left - this._prevScrollX,
- -evt.mcs.top - this._prevScrollY);
-
- if (!offset.equals(new L.Point(0, 0))) {
- this._prevScrollY = -evt.mcs.top;
- this._prevScrollX = -evt.mcs.left;
- this._map.panBy(offset, {animate:false});
- }
- },
-
- _onScrollEnd: function (evt) {
- this._prevScrollY = -evt.mcs.top;
- this._prevScrollX = -evt.mcs.left;
- },
-
_preFetchTiles: function () {
if (this._permission === 'edit') {
return;
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 45255f7..f8ddb5e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -102,11 +102,9 @@ L.TileLayer = L.GridLayer.extend({
this.sendMessage('load url=' + this.options.doc);
this.sendMessage('status');
}
- this._map._scrollContainer.onscroll = L.bind(this._onScroll, this);
- this._map.on('zoomend resize', this._updateScrollOffset, this);
+ this._map.on('drag resize zoomend', this._updateScrollOffset, this);
this._map.on('zoomstart zoomend', this._onZoom, this);
this._map.on('clearselection', this._clearSelections, this);
- this._map.on('drag', this._updateScrollOffset, this);
this._map.on('copy', this._onCopy, this);
this._startMarker.on('drag dragend', this._onSelectionHandleDrag, this);
this._endMarker.on('drag dragend', this._onSelectionHandleDrag, this);
@@ -425,7 +423,7 @@ L.TileLayer = L.GridLayer.extend({
center = center.subtract(this._map.getSize().divideBy(2));
center.x = center.x < 0 ? 0 : center.x;
center.y = center.y < 0 ? 0 : center.y;
- $('#scroll-container').mCustomScrollbar('scrollTo', [center.y, center.x]);
+ this._map.fire('scrollto', {x: center.x, y: center.y});
}
var polygons = L.PolyUtil.rectanglesToPolygons(rectangles, this);
@@ -595,7 +593,7 @@ L.TileLayer = L.GridLayer.extend({
center = center.subtract(this._map.getSize().divideBy(2));
center.x = center.x < 0 ? 0 : center.x;
center.y = center.y < 0 ? 0 : center.y;
- $('#scroll-container').mCustomScrollbar('scrollTo', [center.y, center.x]);
+ this._map.fire('scrollto', {x: center.x, y: center.y});
}
}
else if (this._cursorMarker) {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index b2d2999..1cf4091 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -19,13 +19,13 @@ L.Map = L.Evented.extend({
markerZoomAnimation: true
},
- initialize: function (id, scrollContId, mockDocId, options) { // (HTMLElement or String, Object)
+ initialize: function (id, options) { // (HTMLElement or String, Object)
options = L.setOptions(this, options);
if (options.server) {
this._initSocket();
}
- this._initContainer(id, scrollContId, mockDocId);
+ this._initContainer(id);
this._initLayout();
// hack for https://github.com/Leaflet/Leaflet/issues/1980
@@ -449,10 +449,8 @@ L.Map = L.Evented.extend({
},
- _initContainer: function (id, scrollContId, mockDocId) {
+ _initContainer: function (id) {
var container = this._container = L.DomUtil.get(id);
- var scrollContainer = this._scrollContainer = L.DomUtil.get(scrollContId);
- var mockDoc = this._mockDoc = L.DomUtil.get(mockDocId);
if (!container) {
throw new Error('Map container not found.');
@@ -460,14 +458,6 @@ L.Map = L.Evented.extend({
throw new Error('Map container is already initialized.');
}
- if (!scrollContainer) {
- throw new Error('Scroll container not found.');
- }
-
- if (!mockDoc) {
- throw new Error('Mock document div not found.');
- }
-
var textAreaContainer = L.DomUtil.create('div', 'clipboard-container', container.parentElement);
this._textArea = L.DomUtil.create('textarea', 'clipboard', textAreaContainer);
@@ -771,6 +761,6 @@ L.Map = L.Evented.extend({
}
});
-L.map = function (id, scrollContId, mockDocId, options) {
- return new L.Map(id, scrollContId, mockDocId, options);
+L.map = function (id, options) {
+ return new L.Map(id, options);
};
More information about the Libreoffice-commits
mailing list