Skip to content

Commit

Permalink
fix: clone getters of EntryText
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 30, 2023
1 parent c79f7b7 commit 7f0145a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/obj/EntryContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,21 @@ export abstract class EntryContainer extends EventEmitter {
*/
protected dataUpdate(_sprite: this) {}

clone(project: Entry) {
const sprite = new (this.constructor as new (data: EntryContainerData) => this)({
...this,

// Object spread doesn't contain getters
cloneGetters() {
return {
size: this.size,
x: this.x,
y: this.y,
rotation: this.rotation,
visible: this.visible,
transparency: this.transparency,
}
}

clone(project: Entry) {
const sprite = new (this.constructor as new (data: EntryContainerData) => this)({
...this,
...this.cloneGetters(),

isClone: true,
})
Expand Down
10 changes: 10 additions & 0 deletions src/obj/EntryText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ export class EntryText extends EntryBrush {
}
}

cloneGetters() {
return {
...super.cloneGetters(),
text: this.text,
colour: this.colour,
textAlign: this.textAlign,
fontSize: this.fontSize,
}
}

init() {
this.pixiSprite = new Text({
renderMode: "html",
Expand Down

0 comments on commit 7f0145a

Please sign in to comment.