-
Notifications
You must be signed in to change notification settings - Fork 100
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
Change custom actions for each different type of object (Image/Circle/Text/etc...) #28
Comments
Hey there, thank you for taking the time to write this up. The general problem here is that in the fabric.js core the corner actions, as you correctly stated, inherit from the fabric.Canvas prototype which basicly means there is no way to define these for each individual object without some serious shifting of functions which in my opinion would be very hard task to do and to maintain in the future. I am generally up to any PRs and suggestions concerning this but i do not have the time currently to make this happen on my own. Simon |
No worries I understand the time issue; I'm sure it's possible to just dynamically change it each time an object is selected and/or added. Could possibly set the function '.customiseControls()' on the 'object:added object:selected' events and just declare the type when adding the object originally. I'll try to see if I can get a jsfiddle up later when I'm free'd up. Logically makes sense but guess we'll see in a bit. Thanks for the prompt response @MDSLKTR. |
@MDSLKTR It seems to be working if you get time check out the jsFiddle. |
@craziduezi Hey again, this is actually a very clever workaround binding this to an event handler. If there are no issues performance-wise i would like to add this tipp to the docs since a real change of core behaviour is unlikely from my part in the near future. This should be good enough to satisfy most use cases. Great stuff. |
Thank you! So, this is the initial setup I had to use but I found a small issue when overwriting.
Lastly, the 'object:selected' listener. This will handle the change and default icon/actions of activeObject or activeGroup independently.
BTW, not sure where to put this but I created an extra useful action for the extension. Thought somebody could get some use out of it.
Then referenced the action 'changeColor' to the '_changeColor' function
use as:
|
Accidentally closed / I think that's about all we can do with it for now anyways. Thanks again @MDSLKTR |
@craziduezi Yeah i think so too, this is a great reference, i will update the docs with this link and close for now, great work! |
Hi there, great customisation extension for fabricjs! I had a quick question though. I'm originally setting the customised options when I initiate the canvas. Giving the objects all the same customised controls. The issue is that when I add an image (new fabric.Image) and try to change the controls; I'm able to set the custom icons for the Image but the actions still is inherited from the general settings.
The actual error I'm receiving from console is "Uncaught TypeError: img.customizeControls is not a function".
*note - This note from your README.md
It makes me think it's just a general setting and would need to extended to each individual object. Anyways I appreciate the help in advance and again love the extension!
The text was updated successfully, but these errors were encountered: