Browse files

ESC key cancels card drag if one accidentally starts to drag a card (…

…sensitive touchpad, cruddy mouse, etc.)
  • Loading branch information...
1 parent 8494cda commit 203e5404fb7c7ebb144ecb8c42c844c60e03332a @tboronczyk tboronczyk committed Jul 3, 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 203e540

Please sign in to comment.