konvajs / konva

Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://konvajs.org/
Other
11.43k stars 918 forks source link

Feature Request: Transformer support custom create anchor #1737

Open leecz opened 6 months ago

leecz commented 6 months ago

to solve the problem: arrow transform like excalidraw's arrow

I wish to have a function createCustomAnchor in Transformer class like _createAnchor, and this function will return the created anchor,so i can bind event handlers to them 。

Thank you for this great library!

bogdan-nourescu commented 5 months ago

@leecz You can use anchorStyleFunc. That function receives 1 Shape as argument

bogdan-nourescu commented 5 months ago

Another way to do that, you can use .findOne to get each of the corners by name and add the event listeners on them. Transformer is just a Group, so you can use multiple ways to get the elements inside

leecz commented 5 months ago

@bogdan-nourescu Thanks! I tried。 It can barely achieve the requirements, but the effect is not good and it is a bit complicated because it needs to switch between two types of transformers。

It would be better if Tansformer could open an interface for creating custom anchors, and these anchors could automatically listen to built-in transform events (such as _handleMouseMove)。