-
-
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
Add Undo and Redo suppoert #23
Comments
I'll try to move redo/undo into a separate module to be included as part of fabric. Marking as "feature". |
Thanks, We will wait for updates from you to start our project. On Wed, Apr 6, 2011 at 10:25 PM, kangax <
Regards: Rizwan Ullah CurioLogix | A Web 2.0,Multimedia and Mobile 2.0 Specialist Company |
This isn't priority issue so closing for now. |
Did you ever add this support? Thanks! |
No, haven't added yet. |
undo/redo...do you have any thoughts on how it could be done? I'll create a module for it but would be nice to get some feedback as I"m sure you've thought about how it might be accomplished. |
After further review I'm not so sure this can be obtained very gracefully by the library itself. I say this because the library would need to be aware of all custom events so as to know when to save state. My point is although I'd love this feature I decided to simply create custom listeners (a dispatcher if you will) that fires and passes what I need when events that affect state are fired. It works very well. With that said on large objects (canvas with many complex items) I would limit undo steps. Google dispatcher or custom listeners and you'll get some concepts. Once you understand the scope of how they work implement on your desired events(your custom functions like myfunc.add.circle or whatever) when this fires pass in the datalessjson representation to an array. When you undo, grab the last item in the array and then delete that item or conversely add it to a "redo" array. Really not hard at all once I thought about it. In fact again I'm not sure its really a good idea to include an "Undo" in the fabric.js library unless Kangax creates the ui as well if that makes sense. Perhaps the author can chime in if he catches this. |
There's some foundation for state saving/checking in fabric: "stateful" As I try to modularize fabric more, I think we might refactor that kangax On Sat, Jun 2, 2012 at 7:15 PM, Origin1 Technologies <
|
I'll play with that and see what I come up with. This is one of those rare deals that if it works well (presenting concept later this week) it will go the distance. You may get your "undo/redo" built for you! I'll keep you posted. -----Original Message----- There's some foundation for state saving/checking in fabric: "stateful" As I try to modularize fabric more, I think we might refactor that functionality into a separate module in a near future. kangax On Sat, Jun 2, 2012 at 7:15 PM, Origin1 Technologies < [email protected]
Reply to this email directly or view it on GitHub: |
i did overlayme.com/page/app/xindex.php |
Hey @luklukls. Looks nice! I'm curious about couple of things:
|
see my page/app/app.js |
luklukls, that link does not seem to be working anymore. Would it be possible to share it again ? ... I believe I can use the same idea for a whiteboard implementation (https://groups.google.com/forum/?fromgroups#!topic/fabricjs/wqmWC-UgLew). |
Anything new about undo/redo feature? |
I am allowing the user to remove the last added path (in my painting application), this works fine for me:
But you could just as easily remove that IF statement and allow them to remove anything. |
@chrisrickard great work for me for undo |
cool 2015-06-10 15:14 GMT+07:00 Anant [email protected]:
Lukluk Luhuring S. S.Kom, MT |
do we have state present in object to detect when it is added or moved |
Yes, you can look up here: http://fabricjs.com/events/ There's event inspector and you can observe these events. |
has any one done undo feature on a group object |
+1 |
@luklukls your link overlayme.com/page/app/xindex.php not working can you please share the updated link of app |
Any update on this? It would be great to have this as a separate module. |
@paulcredmond undo redo feature can be built with fromObject/ toObject. |
i wrote undo/redo functions. Here is fiddle: |
@AlexanderIstomin One click in both direction is false. |
I have implemented Undo Redo using Canvas states. Take a look. Could be useful to someone. I have also provided a Demo URL |
Any update on this ? |
Undo redo is a specific application feature and not a canvas one. It won t be part of fabric.js |
I made an implementation of this as well if it's useful for anyone: https://github.com/paulcredmond/fabric-undoredo |
Small Documentation Fix
To track the state, I'm using JSON.stringify(canvas) and canvas.loadFromJSON() and have an event registered on the object:modified to capture the state. |
well the bigger the design the more expensive, untill is not slow is still ok. Updating part of the json is complicated and can give you mutability problem. An harder alternative is saving just the differences but is a path full of errors to solve. The problems comes when you handle multi selections in which what is changed is harder to find. |
Hey, Andrea (@asturur ) for now I have decided to stick to saving the canvas json. In time if I find that its expensive or is causing issues, I will restrict to saving only the last 10 iterations on the canvas. |
i mean if you have 600 objects on the canvas, and you do toJson and stringfy, will take some ms. If is ok, keep this approach. If you have 20 objects and not crazy groups with hundreds of objects, it will be ok |
Hi @asturur , that's much clear now. |
I want to use this library but main feature of my application is undo & redo,Can you please guide me how could I handle it as you people did in http://printio.ru/ringer_man_tees/new
Regards,
Rizwan Ullah
[email protected]
The text was updated successfully, but these errors were encountered: