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

koTransform does nothing #35

Open
jcerar opened this issue Sep 6, 2024 · 4 comments
Open

koTransform does nothing #35

jcerar opened this issue Sep 6, 2024 · 4 comments

Comments

@jcerar
Copy link

jcerar commented Sep 6, 2024

Describe the bug
Adding koTransform to an element does not appear to actually enable the transformations in the UI either on load or through user interaction (mouseover / click / doubleclick etc.)

To Reproduce
Steps to reproduce the behavior:

  1. create a sample component with ko-circle element as per the KoTransformDirective section of the README, taking care to fix the typos (Tranform -> Transform).
  2. view in browser and attempt to initiate transform

Expected behavior
Resize/rotate handles should appear on the element.

Additional context
I think the problem is the koTransform directive does not set up the Konva.Transformer that actually enables transformations in the UI.

@giovanni-bertoncelli
Copy link
Contributor

Hi, thank you for the issue, I won't be able to look at this in the next few days. Feel free to PR

@giovanni-bertoncelli
Copy link
Contributor

On a second look, take in account that KoTransform allows you to listen to transform events, not transforming the object. For reference these types of events: https://konvajs.org/docs/select_and_transform/Transform_Events.html. No handles or user interaction gestures are enabled through that directive, I've probably misunderstood the API.

@jcerar
Copy link
Author

jcerar commented Sep 6, 2024

Well yes, this is in line with what I am saying. Quoting the very first line from the link you provided in your answer:

Konva.Transformer object has special transform events that you can use in your app: transformstart, transform and transformend.

There will be no transform events without first creating a transformer and attaching the element that will subsequently receive the events on user interaction with said transformer.

Specifically these lines in the code sample are the secret sauce that makes this happen:

      // create new transformer
      var tr = new Konva.Transformer();
      layer.add(tr);
      tr.nodes([rect]);

Obviously this could also be implemented in a wrapper ko-transformer element but it looks to me like there would only need to be a minor tweak to the koTransform directive to get something basic going. I can give it a shot if this sounds like the way to go you.

@giovanni-bertoncelli
Copy link
Contributor

You are actually right, my mistake, I didn't look at the Transform API very deeply when I implemented this. If you want to try feel free to PR! Thank you!

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

No branches or pull requests

2 participants