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

Rect absoluteScale incorrect when a negative X scale is applied, also affects transformer anchors #1712

Open
MadeByMike opened this issue Jan 24, 2024 · 1 comment

Comments

@MadeByMike
Copy link
Contributor

Apply a negative X scale to a rect:

const rect = new Konva.Rect({
  ...
  scale:{
    x: -1,
    y: 1
  }
 });
 
console.log(rect.getAbsoluteScale()) // { x: 1, y: -1 }

The absolute scale will be inverted.

It also impacts transformer handles. Add the item to a transformer and the handles will be flipped. This doesn't happen with a negative Y scale or with multi-selection.

I've created a pen with a demo of this bug: https://codepen.io/MadeByMike/pen/Jjzrymj/b4866fd662e3878546ad52bd999c0f1f

It feels somewhat related to this old issue: #983 but there is no rotation involved. Logging the rotation of every item on the stage shows all to be 0 unless inside a transformer.

I think the behavior of the transformer should be consistent with multi-item selection, in that, the anchors should only change if the transformer itself is rotated or scaled.

@lavrton
Copy link
Member

lavrton commented Mar 14, 2024

For now, I don't know what will be the solution. getAbsoluteScale() is using transformation matrix decomposition. And this is how the current implementation works. Visually, { x: 1, y: -1 } and { x: -1, y: 1 } looks the same.

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