Billy Adelphia
Billy Adelphia

Reputation: 1027

Konvajs how to dragging a Transformer programatically

I want my transformer dragging the bottom-right down and up automatically to a certain point when the page is loaded without user interaction. But I can't find a way to do that.

Here my transformer

  const tr = new Konva.Transformer({
    keepRatio: true,
    borderStrokeWidth: 3,
    borderStroke: "blue",
    enabledAnchors: ['top-left', 'top-right', 'bottom-left', 'bottom-right']
  });

Upvotes: 0

Views: 146

Answers (1)

Vanquished Wombat
Vanquished Wombat

Reputation: 9525

Transformer size matches the size of the shapes within it. In your use case of showing that the height of an image can be changed, set the height of the image and call transformer.forceUpdate() to ensure the transformer sees the change.

See https://konvajs.org/docs/select_and_transform/Force_Update.html

Upvotes: 0

Related Questions