Consistent mouse event propagation in Marker and Path
Marker was missing mouseup and mousemove. Path was missing mouseup.
This commit is contained in:
parent
1b7977a259
commit
4015f49615
@ -67,6 +67,7 @@
|
||||
<!-- /layer/vector/ -->
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleMarkerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PathSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolygonSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineGeometrySpec.js"></script>
|
||||
|
@ -1,10 +1,22 @@
|
||||
describe("Marker", function () {
|
||||
var map,
|
||||
spy;
|
||||
var map;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div')).setView([0, 0], 0);
|
||||
});
|
||||
|
||||
it("propagates events from the icon", function() {
|
||||
var events = ['mousedown', 'mouseup', 'mouseover', 'mouseout',
|
||||
'mousemove', 'dblclick'];
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var marker = new L.Marker([0, 0]).addTo(map),
|
||||
spy = sinon.spy();
|
||||
marker.on(events[i], spy);
|
||||
happen[events[i]](marker._icon);
|
||||
expect(spy.called).to.be.ok();
|
||||
}
|
||||
});
|
||||
|
||||
describe("#setIcon", function () {
|
||||
it("changes the icon to another image", function () {
|
||||
var marker = new L.Marker([0, 0], {icon: new L.Icon({iconUrl: 'icon1.png' }) });
|
||||
|
19
spec/suites/layer/vector/PathSpec.js
Normal file
19
spec/suites/layer/vector/PathSpec.js
Normal file
@ -0,0 +1,19 @@
|
||||
describe("Path", function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div')).setView([0, 0], 0);
|
||||
});
|
||||
|
||||
it("propagates events from the container", function() {
|
||||
var events = ['mousedown', 'mouseup', 'mouseover', 'mouseout',
|
||||
'mousemove', 'dblclick'];
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var path = new L.Path().addTo(map),
|
||||
spy = sinon.spy();
|
||||
path.on(events[i], spy);
|
||||
happen[events[i]](path._container);
|
||||
expect(spy.called).to.be.ok();
|
||||
}
|
||||
});
|
||||
});
|
@ -214,7 +214,8 @@ L.Marker = L.Class.extend({
|
||||
// TODO refactor into something shared with Map/Path/etc. to DRY it up
|
||||
|
||||
var icon = this._icon,
|
||||
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
||||
events = ['mousedown', 'mouseup', 'mouseover', 'mouseout',
|
||||
'mousemove', 'dblclick', 'contextmenu'];
|
||||
|
||||
L.DomUtil.addClass(icon, 'leaflet-clickable');
|
||||
L.DomEvent.on(icon, 'click', this._onMouseClick, this);
|
||||
|
@ -109,8 +109,8 @@ L.Path = L.Path.extend({
|
||||
|
||||
L.DomEvent.on(this._container, 'click', this._onMouseClick, this);
|
||||
|
||||
var events = ['dblclick', 'mousedown', 'mouseover',
|
||||
'mouseout', 'mousemove', 'contextmenu'];
|
||||
var events = ['mousedown', 'mouseup', 'mouseover', 'mouseout',
|
||||
'mousemove', 'dblclick', 'contextmenu'];
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user