Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: When binding an array of events, don't duplicate #1265

Merged
merged 1 commit into from
Mar 28, 2023
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: 3 additions & 1 deletion src/pixelmapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ var pixelmapLayer = function (arg) {
['modified', 'geoOn', 'geoOff', 'geoOnce'].forEach((funcName) => {
const superFunc = m_this[funcName];
m_this[funcName] = function () {
m_pixelmapFeature[funcName].apply(this, arguments);
if (!Array.isArray(arguments[0])) {
m_pixelmapFeature[funcName].apply(this, arguments);
}
return superFunc.apply(this, arguments);
};
});
Expand Down
19 changes: 19 additions & 0 deletions tests/gl-cases/pixelmapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ describe('webglPixelmapLayer', function () {
done();
});
});
it('geoOn and geoOff from array', function (done) {
createPixelmap();
var click = 0;
layer.geoOn([geo.event.feature.mouseclick], () => {
click += 1;
});
// wait for the tiles to be available
map.onIdle(() => {
expect(click).toEqual(0);
map.interactor().simulateEvent('mousedown', {map: {x: 390, y: 200}});
map.interactor().simulateEvent('mouseup', {map: {x: 390, y: 200}});
expect(click).toEqual(1);
layer.geoOff([geo.event.feature.mouseclick]);
map.interactor().simulateEvent('mousedown', {map: {x: 390, y: 200}});
map.interactor().simulateEvent('mouseup', {map: {x: 390, y: 200}});
expect(click).toEqual(1);
done();
});
});
it('geospatial', function (done) {
map = geo.map({node: '#map'});
layer = map.createLayer('pixelmap', {
Expand Down