diff options
| author | Julie Lala <jules@okfoc.us> | 2014-08-15 09:26:10 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-08-15 09:26:10 -0400 |
| commit | aecaf2de2b4ed5277b34e9209a0f31602e8a7999 (patch) | |
| tree | 78e46648032b91ebb0267e38f39f6227da7d8732 /public/assets/javascripts/rectangles/engine/scenery/move.js | |
| parent | 02bde51c24ae1c6e189d031b80226e6a9f7cbc59 (diff) | |
| parent | 1be685f9fe4a7f3a3e947d45f865fe07c03ddbaf (diff) | |
Merge branch 'walls' of github.com:okfocus/vvalls into walls
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/scenery/move.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/scenery/move.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js index cc5b014..f2d37d8 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/move.js +++ b/public/assets/javascripts/rectangles/engine/scenery/move.js @@ -3,6 +3,7 @@ Scenery.move = function(base){ var x, y, z, bounds var dragging = false + var oldState this.bind = function(){ Scenery.mouse.bind_el(base.mx.el) @@ -23,6 +24,15 @@ Scenery.move = function(base){ function down (e, cursor){ if (e.target != base.mx.el) return; if (editor.permissions.destroy) { + UndoStack.push({ + type: 'destroy-scenery', + undo: base.serialize(), + redo: { id: base.id }, + }) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + Scenery.remove(base.id) return } @@ -39,6 +49,7 @@ Scenery.move = function(base){ y = base.mx.y z = base.mx.z bounds = base.bounds + oldState = base.serialize() document.body.classList.add("dragging") } @@ -63,8 +74,21 @@ Scenery.move = function(base){ } function up (e, cursor){ + if (! dragging || ! oldState) return + dragging = false document.body.classList.remove("dragging") + + UndoStack.push({ + type: 'update-scenery', + undo: oldState, + redo: base.serialize(), + }) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + + oldState = null } function switch_wall (e, new_wall, cursor){ |
