Leaflet 1.0: revert touch style in desktop browsers, fixes #69
This commit is contained in:
parent
6c316c8688
commit
cd6c1bdc54
3 changed files with 34 additions and 0 deletions
|
|
@ -31,6 +31,7 @@ var paths = {
|
||||||
'!**/*.min.js',
|
'!**/*.min.js',
|
||||||
'!**/url-search-params/**/*.js'
|
'!**/url-search-params/**/*.js'
|
||||||
]).concat([
|
]).concat([
|
||||||
|
'js/Browser.js',
|
||||||
'js/Util.js',
|
'js/Util.js',
|
||||||
'js/Map.js',
|
'js/Map.js',
|
||||||
'js/router/BRouter.js',
|
'js/router/BRouter.js',
|
||||||
|
|
|
||||||
24
js/Browser.js
Normal file
24
js/Browser.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
var touchScreen = (function () {
|
||||||
|
var result = null;
|
||||||
|
|
||||||
|
if ('maxTouchPoints' in navigator) {
|
||||||
|
result = navigator.maxTouchPoints > 0;
|
||||||
|
} else if (window.matchMedia && window.matchMedia('(any-pointer:coarse),(any-pointer:fine),(any-pointer:none)').matches) {
|
||||||
|
result = window.matchMedia("(any-pointer:coarse)").matches;
|
||||||
|
} else if ('msMaxTouchPoints' in navigator) {
|
||||||
|
result = navigator.msMaxTouchPoints > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}()),
|
||||||
|
touchScreenDetectable = touchScreen !== null;
|
||||||
|
|
||||||
|
|
||||||
|
BR.Browser = {
|
||||||
|
touchScreen: touchScreen,
|
||||||
|
touchScreenDetectable: touchScreenDetectable
|
||||||
|
};
|
||||||
|
|
||||||
|
}());
|
||||||
|
|
@ -8,6 +8,14 @@
|
||||||
|
|
||||||
var mapContext;
|
var mapContext;
|
||||||
|
|
||||||
|
function verifyTouchStyle(mapContext) {
|
||||||
|
// revert touch style (large icons) when touch screen detection is available and negative
|
||||||
|
// see https://github.com/nrenner/brouter-web/issues/69
|
||||||
|
if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
|
||||||
|
L.DomUtil.removeClass(mapContext.map.getContainer(), 'leaflet-touch');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initApp(mapContext) {
|
function initApp(mapContext) {
|
||||||
var map = mapContext.map,
|
var map = mapContext.map,
|
||||||
layersControl = mapContext.layersControl,
|
layersControl = mapContext.layersControl,
|
||||||
|
|
@ -340,6 +348,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
mapContext = BR.Map.initMap();
|
mapContext = BR.Map.initMap();
|
||||||
|
verifyTouchStyle(mapContext);
|
||||||
initApp(mapContext);
|
initApp(mapContext);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue