Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/map/Map.DomEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ Map.include(/** @lends Map.prototype */ {
}

const eventParam = this._parseEvent(e, type);
//mouse point Beyond the visible range of the map(Sky Box Area)
if (!eventParam.coordinate && type !== 'keypress' && type.indexOf('dom:') === -1) {
return;
}
this._wrapTerrainData(eventParam);
if (isMoveEvent(type)) {
this.getRenderer().callInNextFrame(() => {
Expand Down
105 changes: 68 additions & 37 deletions test/map/MapEventSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Map.Event', function () {
container.style.height = '20px';
document.body.appendChild(container);
var option = {
zoomAnimation:false,
zoomAnimation: false,
zoom: 17,
center: center
};
Expand All @@ -31,13 +31,13 @@ describe('Map.Event', function () {
map.on('click', spy);

happen.mousedown(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
setTimeout(function () {
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
done();
Expand All @@ -51,17 +51,17 @@ describe('Map.Event', function () {
map.on('click', spy);

happen.once(eventContainer, {
'type' : 'touchstart',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchstart',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
happen.once(eventContainer, {
'type' : 'touchend',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchend',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
expect(spy.called).to.be.ok();
Expand All @@ -74,31 +74,31 @@ describe('Map.Event', function () {
map.on('dblclick', spy);

happen.once(eventContainer, {
'type' : 'touchstart',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchstart',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
happen.once(eventContainer, {
'type' : 'touchend',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchend',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
happen.once(eventContainer, {
'type' : 'touchstart',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchstart',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
happen.once(eventContainer, {
'type' : 'touchend',
'touches' : [{
'clientX':point.x,
'clientY':point.y
'type': 'touchend',
'touches': [{
'clientX': point.x,
'clientY': point.y
}]
});
expect(spy.called).to.be.ok();
Expand All @@ -110,18 +110,18 @@ describe('Map.Event', function () {
var spy = sinon.spy();
map.once('click', spy);
happen.mousedown(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).to.be.ok();
spy.reset();
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
});
Expand All @@ -132,8 +132,8 @@ describe('Map.Event', function () {
var spy = sinon.spy();
map.on('click', spy);
happen.click(eventContainer, {
'clientX':point.x,
'clientY':point.y
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
});
Expand Down Expand Up @@ -165,4 +165,35 @@ describe('Map.Event', function () {
});
expect(spy.called).not.to.be.ok();
});

it('block map mouse event when point in sky area', function (done) {
Object.assign(container.style, { width: '1000px', height: '500px' });

setTimeout(() => {
map.setPitch(80);
const { width, height } = map.getSize();
const point = new maptalks.Point(width / 2, 2);
var spy = sinon.spy();
const spy1 = sinon.spy();
map.on('click', spy);
map.on('dom:click', spy1);

happen.mousedown(eventContainer, {
'clientX': point.x,
'clientY': point.y
});
setTimeout(function () {
happen.click(eventContainer, {
'clientX': point.x,
'clientY': point.y
});
expect(spy.called).not.to.be.ok();
expect(spy1.called).to.be.ok();
done();
}, 500);


}, 500);

});
});