loleaflet/src/layer/marker/Cursor.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
New commits: commit 37eacf06ce320ba6373f9326dc1eda66889e7697 Author: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> AuthorDate: Sun Nov 24 14:21:43 2019 +0100 Commit: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> CommitDate: Mon Nov 25 16:12:32 2019 +0100 Enable zoom animation for cursor It prevents cursor from appearing in old position on large zoom level difference (pinch to zoom). It also provides nicer visual effect on desktop. Change-Id: I9e2504dc54c47196441a1ea16e3422cce137d5a2 Reviewed-on: https://gerrit.libreoffice.org/83610 Reviewed-by: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> Tested-by: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> diff --git a/loleaflet/src/layer/marker/Cursor.js b/loleaflet/src/layer/marker/Cursor.js index 592658dca..b7a0ba1a9 100644 --- a/loleaflet/src/layer/marker/Cursor.js +++ b/loleaflet/src/layer/marker/Cursor.js @@ -7,7 +7,8 @@ L.Cursor = L.Layer.extend({ options: { opacity: 1, - zIndex: 1000 + zIndex: 1000, + zoomAnimation: true }, initialize: function (latlng, size, options) { @@ -22,6 +23,11 @@ L.Cursor = L.Layer.extend({ this._initLayout(); } + this._zoomAnimated = this._zoomAnimated && this.options.zoomAnimation; + if (this._zoomAnimated) { + L.DomUtil.addClass(this._container, 'leaflet-zoom-animated'); + } + this.update(); this.getPane().appendChild(this._container); }, @@ -35,6 +41,10 @@ L.Cursor = L.Layer.extend({ getEvents: function () { var events = {viewreset: this.update}; + if (this._zoomAnimated) { + events.zoomanim = this._animateZoom; + } + return events; }, @@ -117,6 +127,11 @@ L.Cursor = L.Layer.extend({ _setSize: function () { this._cursor.style.height = this._size.y + 'px'; this._container.style.top = '-' + (this._container.clientHeight - this._size.y - 2) / 2 + 'px'; + }, + + _animateZoom: function (opt) { + var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round(); + L.DomUtil.setPosition(this._container, pos); } }); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits