nakarte

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

commit 3f6fb56bdcf64f76659cb844641b99b2ba320698
parent 13f77c2769986719c7083c6a5712008fd7cdc6b1
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Wed, 15 Feb 2017 22:44:53 +0300

[leaflet fixes] fix panning only in chrome; fix touch detection

Diffstat:
Msrc/App.js | 4++--
Dsrc/lib/leaflet.fixAnimationBug/index.js | 16----------------
Asrc/lib/leaflet.fixes/index.js | 28++++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/src/App.js b/src/App.js @@ -9,7 +9,7 @@ import 'lib/leaflet.control.coordinates'; import enableLayersControlHotKeys from 'lib/leaflet.control.layers.hotkeys'; import 'lib/leaflet.hashState/Leaflet.Map'; import 'lib/leaflet.hashState/Leaflet.Control.Layers'; -import fixAnimationBug from 'lib/leaflet.fixAnimationBug' +import {fixAll} from 'lib/leaflet.fixes' import './adaptive.css'; import 'lib/leaflet.control.panoramas'; import 'lib/leaflet.control.track-list/track-list'; @@ -26,7 +26,7 @@ import getLayers from 'layers'; function setUp() { - fixAnimationBug(); + fixAll(); const map = L.map('map', { zoomControl: false, diff --git a/src/lib/leaflet.fixAnimationBug/index.js b/src/lib/leaflet.fixAnimationBug/index.js @@ -1,15 +0,0 @@ -import L from 'leaflet'; - -// https://github.com/Leaflet/Leaflet/issues/3575 - -const originalStep = L.PosAnimation.prototype._step - -function _step() { - return originalStep.call(this, true); -} - -export default function fixAnimationBug() { - if (L.PosAnimation.prototype._step !== _step) { - L.PosAnimation.prototype._step = _step; - } -} -\ No newline at end of file diff --git a/src/lib/leaflet.fixes/index.js b/src/lib/leaflet.fixes/index.js @@ -0,0 +1,28 @@ +import L from 'leaflet'; + +function fixAll() { + fixPanAnimationBug(); + fixTouchDetection(); +} + +// https://github.com/Leaflet/Leaflet/issues/3575 +function fixPanAnimationBug() { + if (!L.Browser.chrome) { + return; + } + if (L.PosAnimation.prototype.__panAnimationFixed) { + return; + } + + const originalStep = L.PosAnimation.prototype._step; + L.PosAnimation.prototype._step = function() { + return originalStep.call(this, true); + }; + L.PosAnimation.prototype.__panAnimationFixed = true; +} + +function fixTouchDetection() { + L.Browser.touch &= (navigator.pointerEnabled || navigator.maxTouchPoints) +} + +export {fixAll}