#5921 Remove touch based click tolerance (#5922)

This commit is contained in:
Martin Palmér 2017-11-17 14:36:23 +01:00 committed by Per Liedman
parent 127c023f18
commit 1d8cc53408
3 changed files with 18 additions and 3 deletions

View File

@ -80,5 +80,17 @@ describe('Path', function () {
}, 300);
});
it('it should return tolerance with stroke', function () {
var path = new L.Polyline([[1, 2], [3, 4], [5, 6]]);
var layer = path.addTo(map);
expect(path._clickTolerance()).to.equal(path.options.weight / 2);
});
it('it should return zero tolerance without stroke', function () {
var path = new L.Polyline([[1, 2], [3, 4], [5, 6]]);
var layer = path.addTo(map);
path.options.stroke = false;
expect(path._clickTolerance()).to.equal(0);
});
});
});

View File

@ -1,6 +1,5 @@
import {Layer} from '../Layer';
import * as Util from '../../core/Util';
import {touch} from '../../core/Browser';
/*
* @class Path
@ -140,6 +139,6 @@ export var Path = Layer.extend({
_clickTolerance: function () {
// used when doing hit detection for Canvas layers
return (this.options.stroke ? this.options.weight / 2 : 0) + (touch ? 10 : 0);
return (this.options.stroke ? this.options.weight / 2 : 0) + this._renderer.options.tolerance;
}
});

View File

@ -34,7 +34,11 @@ export var Renderer = Layer.extend({
// @option padding: Number = 0.1
// How much to extend the clip area around the map view (relative to its size)
// e.g. 0.1 would be 10% of map view in each direction
padding: 0.1
padding: 0.1,
// @option tolerance: Number = 0
// How much to extend click tolerance round a path/object on the map
tolerance : 0
},
initialize: function (options) {