Skip to content
Browse files

Merge pull request #52 from tboronczyk/drag-cancel

ESC key cancels card drag
  • Loading branch information...
2 parents 8c17188 + 203e540 commit 92e5469ea4a5b1a1f1d5e8ac5fec0456fa0483d1 @aliasaria committed Dec 8, 2013
Showing with 19 additions and 4 deletions.
  1. +19 −4 client/script.js
View
23 client/script.js
@@ -3,7 +3,7 @@ var totalcolumns = 0;
var columns = [];
var currentTheme = "bigcards";
var boardInitialized = false;
-
+var keyTrap = null;
var socket = io.connect();
@@ -154,7 +154,9 @@ function getMessage( m )
}
-
+$(document).bind('keyup', function(event) {
+ keyTrap = event.which;
+});
function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
{
@@ -185,12 +187,25 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
snap: false,
snapTolerance: 5,
containment: [0,0,2000,2000],
- stack: ".card"
+ stack: ".card",
+ start: function (event, ui) {
+ keyTrap = null;
+ },
+ drag: function (event, ui) {
+ if (keyTrap == 27) {
+ ui.helper.css(ui.originalPosition);
+ return false;
+ }
+ }
}
);
-
+
//After a drag:
card.bind( "dragstop", function(event, ui) {
+ if (keyTrap == 27) {
+ keyTrap = null;
+ return;
+ }
var data = {
id: this.id,

0 comments on commit 92e5469

Please sign in to comment.
Something went wrong with that request. Please try again.