Skip to content

Commit

Permalink
Merge pull request #15143 from tschaub/hit-detect-circle
Browse files Browse the repository at this point in the history
Properly hit detect circles after updating size
  • Loading branch information
tschaub committed Sep 18, 2023
2 parents 70e6da2 + a518abb commit 5075214
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ol/style/RegularShape.js
Expand Up @@ -505,6 +505,7 @@ class RegularShape extends ImageStyle {
this.renderOptions_ = this.createRenderOptions();
const size = this.renderOptions_.size;
this.canvas_ = {};
this.hitDetectionCanvas_ = null;
this.size_ = [size, size];
}

Expand Down
Expand Up @@ -2,7 +2,7 @@ import CircleStyle from '../../../../../src/ol/style/Circle.js';
import Fill from '../../../../../src/ol/style/Fill.js';
import Stroke from '../../../../../src/ol/style/Stroke.js';

describe('ol.style.Circle', function () {
describe('ol/style/Circle', function () {
describe('#constructor', function () {
it('creates a canvas (no fill-style)', function () {
const style = new CircleStyle({radius: 10});
Expand Down Expand Up @@ -126,8 +126,17 @@ describe('ol.style.Circle', function () {
}),
});
expect(style.getRadius()).to.eql(10);

const hitImageBefore = style.getHitDetectionImage();
expect(hitImageBefore).to.be.an(HTMLCanvasElement);
expect(hitImageBefore.width).to.eql(20);

style.setRadius(20);
expect(style.getRadius()).to.eql(20);

const hitImageAfter = style.getHitDetectionImage();
expect(hitImageAfter).to.be.an(HTMLCanvasElement);
expect(hitImageAfter.width).to.eql(40);
});
});
});
Expand Up @@ -2,7 +2,7 @@ import Fill from '../../../../../src/ol/style/Fill.js';
import RegularShape from '../../../../../src/ol/style/RegularShape.js';
import Stroke from '../../../../../src/ol/style/Stroke.js';

describe('ol.style.RegularShape', function () {
describe('ol/style/RegularShape', function () {
describe('#constructor', function () {
it('can use rotateWithView', function () {
const style = new RegularShape({
Expand Down

0 comments on commit 5075214

Please sign in to comment.