handle updateable displacement

This commit is contained in:
mike-000
2021-10-25 10:20:36 +01:00
committed by GitHub
parent 1249ecee45
commit 9267d2994d

View File

@@ -126,12 +126,6 @@ class RegularShape extends ImageStyle {
*/
this.stroke_ = options.stroke !== undefined ? options.stroke : null;
/**
* @private
* @type {Array<number>}
*/
this.anchor_ = null;
/**
* @private
* @type {import("../size.js").Size}
@@ -177,7 +171,12 @@ class RegularShape extends ImageStyle {
* @api
*/
getAnchor() {
return this.anchor_;
const size = this.size_;
if (!size) {
return null;
}
const displacement = this.getDisplacement();
return [size[0] / 2 - displacement[0], size[1] / 2 + displacement[1]];
}
/**
@@ -467,9 +466,7 @@ class RegularShape extends ImageStyle {
render() {
this.renderOptions_ = this.createRenderOptions();
const size = this.renderOptions_.size;
const displacement = this.getDisplacement();
this.canvas_ = {};
this.anchor_ = [size / 2 - displacement[0], size / 2 + displacement[1]];
this.size_ = [size, size];
}