Skip to content

Commit

Permalink
ensure canvas is not painted when hide and show event is fired.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Oct 14, 2024
1 parent 8b1f082 commit d76c3cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/layer/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) {
if (renderer && map && map.getRenderer()) {
//fire show in next frame to make sure layer is shown
map.getRenderer().callInNextFrame(() => {
this.fire('show');
map.getRenderer().callInNextFrame(() => {
this.fire('show');
});
});
} else {
/**
Expand Down Expand Up @@ -459,7 +461,9 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) {
if (renderer && map && map.getRenderer()) {
//fire hide in next frame to make sure layer is hidden
map.getRenderer().callInNextFrame(() => {
this.fire('hide');
map.getRenderer().callInNextFrame(() => {
this.fire('hide');
});
});
} else {
/**
Expand Down
7 changes: 2 additions & 5 deletions test/geometry/AGeometryRemoveHideSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ function test(geometry, context, fn, done) {
})
});
layer.once('hide', function () {

map.once('frameend', function () {
expect(isDrawn(testPoints, context.container)).not.to.be.ok();
done();
})
expect(isDrawn(testPoints, context.container)).not.to.be.ok();
done();
});
fn();
});
Expand Down

0 comments on commit d76c3cf

Please sign in to comment.