-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix object centering when canvas zoomed #2021
Conversation
would you mind making a demo of what is failing without this PR (including the other ) i think that we are speaking about canvas absolute center and viewport center differencies. right? |
Yes, see here http://jsfiddle.net/ombydhqf/1/. When canvas is not zoomed, object is properly centered. It's not when it's zoomed. |
For this PR and the closed one, i think is a matter of definitions. |
Adding this too http://jsfiddle.net/1vbxh3m7/1/. Same as previous one but with canvas dimensions also changed after zoom. |
Whether it's a bug or possible feature, I agree we need to fix it! |
I think it would make sense to change |
Has there been any update on this? |
I'm not sure how we should handle this. @paulcanning did you get how to use internal zoom functions? |
I was able to use the canvas.setZoom method, but the centering broke, as well as the alignment guideline library that someone wrote, so I've gone back to the old method of scaling everything down, until this centering issue is fixed and I figure out how to fix the guidelines. |
https://github.com/kangax/fabric.js/blob/master/lib/aligning_guidelines.js check if this aligning library is what you need. I think it is in working state. |
Yea, just seen it haha! Seems to be ok, and I guess I can work around the centering for now by using the canvas height and width to set the top left coords. |
For anyone coming here via search, a number of new e.g. http://fabricjs.com/docs/fabric.Object.html#viewportCenter This is available as of Fabric.js Version 1.6.3 |
using version 2.3.6 still canvas.centerObject(obj) not centering object when canvas set to custom zoom |
please have a look at docs, there are specific method for it on the StaticCanvas class. make a search for viewport fabricjs.com/docs |
In 2.3.6 what asturur said works. |
This is really fine approach to zoom at center object. Real example :
And its Done. Thank You All........... |
closes #1641 ( edited by asturur )