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

Setting width or height of a Box does not respect isCentered property #70

Closed
joeynenni opened this issue Mar 7, 2024 · 3 comments
Closed

Comments

@joeynenni
Copy link

If you create a Box with isCentered: true option and then adjust the width or height the Box is repositions itself as if isCentered was false.

In order to preserve the isCentered property of the box you currently need to do the following:

const box = new Box({ x: 10, y: 10 }, 5, 5, { isCentered: true })

box.width = 8
box.height = 8

// extra hack to preserve isCentered property
const centroid = box.getCentroidWithoutRotation()
const x = centroid.x * (box.isCentered ? 1 : -1)
const y = centroid.y * (box.isCentered ? 1 : -1)
box.translate(-x, -y)
@Prozi
Copy link
Owner

Prozi commented Mar 23, 2024

@joeynenni thank you very much for this bug report

I will check this and fix in upcoming days

thank you <3

Prozi pushed a commit that referenced this issue Mar 23, 2024
@Prozi
Copy link
Owner

Prozi commented Mar 23, 2024

fixed in ^9.4.1 thanks

@Prozi Prozi closed this as completed Mar 23, 2024
@joeynenni
Copy link
Author

I tested the fix and it works great, thank you!

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