meemoo / meemooapp

Creative apps to use, build, share, and hack in the browser.
http://meemoo.org/hack-our-apps/
GNU Affero General Public License v3.0
259 stars 52 forks source link

warn on close unsaved #104

Open forresto opened 11 years ago

forresto commented 11 years ago

Chrome has a new two-finger scroll to navigate history, which annoyingly erased some unsaved work.

thoughts:

  1. load app or start new
  2. change it
  3. change hash to unsaved
  4. if closed or navigated from that state, warn

Warnings are kinda lame, and an autosave that reloads your last state might be less annoying, but that doesn't help if you have been working on an image or animation...

piatra commented 11 years ago

I've been working on a patch for this. It would use window.onbeforeunload which triggers a native alert giving the user the option to stop the back/forward action that might have been accidentally triggered.

The problem I'm having is that the event isn't triggered if all that changes in the location bar is the hash. You have to navigate to another page/domain etc. But in the case of this app changing the hash might send you away from your app and lose progress. I'm not sure if you can get around this limitation.

How about auto-saves ?

forresto commented 11 years ago

Autosaves can be annoying. onbeforeunload is a good direction I think. http://backbonejs.org/#Router router.on("route", function() {}); might help to listen for internal hash changes.

Note: I'm currently hacking up iframework.js to try to make it more modular and easier to maintain.