nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit c199065376c586a3bc1b754275fa3951c1585b3d
parent bbc58e67920eb337d3023946f558babe496c690b
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Wed, 25 Apr 2018 23:44:43 +0300

update vector layers during zoom and pan animation (#63)

Diffstat:
Msrc/lib/leaflet.fixes/index.js | 40++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/lib/leaflet.fixes/index.js b/src/lib/leaflet.fixes/index.js @@ -5,6 +5,7 @@ function fixAll() { fixPanAnimationBug(); fixTouchDetection(); fixMapKeypressEvent(); + fixVectorDrawWhileAnimation(); } // https://github.com/Leaflet/Leaflet/issues/3575 @@ -38,4 +39,43 @@ function fixMapKeypressEvent() { } } +function fixVectorDrawWhileAnimation() { + if (L.Renderer.__animationFixed) { + return; + } + + const resetInterval = 300; + + const originalGetEvents = L.Renderer.prototype.getEvents; + + const onZoom = function() { + const now = Date.now(); + if (!this._lastReset || (now - this._lastReset > resetInterval)) { + this._reset(); + this._lastReset = now; + } else { + L.Renderer.prototype._onZoom.call(this); + } + + }; + + const onMove = function() { + const now = Date.now(); + if (!this._lastReset || (now - this._lastReset > resetInterval)) { + this._reset(); + this._lastReset = now; + } + }; + + const getEvents = function() { + const result = originalGetEvents.call(this); + result.move = onMove; + result.zoom = onZoom; + return result; + }; + + L.Renderer.prototype.getEvents = getEvents; + L.Renderer.__animationFixed = true; +} + export {fixAll}