Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ESC key cancels card drag #52

Merged
merged 1 commit into from

2 participants

@tboronczyk

ESC key cancels card drag if one accidentally starts to drag a card (because of a sensitive touchpad, cruddy mouse, etc.)

@aliasaria aliasaria merged commit 92e5469 into aliasaria:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 3, 2013
  1. @tboronczyk

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

    tboronczyk authored
    …sensitive touchpad, cruddy mouse, etc.)
This page is out of date. Refresh to see the latest.
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,
Something went wrong with that request. Please try again.