jzaefferer/undo

Undo group of commands

Opened this issue · 3 comments

mskr commented

This is useful when you have many little changes.

For example the user might move a graphical object by drag and drop.

The user would not want to undo every pixel-sized change.

I would like to be able to group some commands, that the user can undo at once.

If the project is still active I would gladly submit a pull request.

If you don't want to track each pixel, how about only adding the result (not the intermediate steps) to the stack?

mskr commented

Hi nice to hear from you!

I think I understand that you want to keep the library small and clean.

However, user-code in Undo.Stack.changed function might want to update the view for every pixel-sized change. At least this is how my code does it at the moment.

I would have to call my update view function elsewhere and add logic to only update the stack for every x pixels...

And I just wondered if the library should be able to help with this use case :)

For extra context: My app is in WebGL and therefore updates view manually.

If you think it is a good idea I will make the PR, but first I would like to merge #11

Thanks for the context, that helps! Seems reasonable to add that to the library!