iBet uBet web content aggregator. Adding the entire web to your favor.
iBet uBet web content aggregator. Adding the entire web to your favor.



Link to original content: http://github.com/konvajs/konva/issues/1833
Transformer/Text width is not being update on font size chanfe · Issue #1833 · konvajs/konva · GitHub
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

Transformer/Text width is not being update on font size chanfe #1833

Open
michalgrzyska opened this issue Oct 6, 2024 · 2 comments
Open

Comments

@michalgrzyska
Copy link

Hi,

I noticed that I cannot resize Transformer (not Text) after I change the fontSize property. If I make my text bigger with the font size, it's being "cut" due to invalid Text's size. Here is my update style code:

    const id = this.selectedText._id;
    const text = this.editor.textLayer.children.find((x) => x._id === id)! as Konva.Text;

    const newFontSize = this.calculateFontSize(options.fontSize!);

    text.setAttrs(options);
    text.fontSize(newFontSize);

    this.editor.transformer?.nodes([text]);
    this.editor.transformer?.forceUpdate();

    setTimeout(() => {
      this.editor.textLayer.draw();
    }, 50);

Nothing is null: text is an object, transformer is an object (there is only one transformer at the moment), editor is an object. Everything work but this.

konva

@michalgrzyska
Copy link
Author

I found one of possible solutions: I am making a deep copy of the text with new fontSize value on init, and replace old text with the new one. But I don't think this is the proper solution.

@lavrton
Copy link
Member

lavrton commented Oct 9, 2024

What konva version do you use? I can't reproduce it with the last version. https://jsbin.com/zagifudoni/1/edit?html,js,output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants