Add delay of 1.5s for draggable items on touch devices

This commit is contained in:
Frederic Guillot
2015-08-29 11:57:09 -04:00
parent f4c3ca9991
commit 720d1bc3bd
14 changed files with 80 additions and 35 deletions

File diff suppressed because one or more lines are too long

View File

@@ -113,12 +113,13 @@ Board.prototype.dragAndDrop = function() {
var self = this;
$(".board-task-list").sortable({
forcePlaceholderSize: true,
delay: 300,
delay: $.support.touch ? 1500 : 300,
distance: 5,
connectWith: ".board-task-list",
placeholder: "draggable-placeholder",
items: ".draggable-item",
stop: function(event, ui) {
ui.item.removeClass("draggable-item-selected");
self.save(
ui.item.attr('data-task-id'),
ui.item.parent().attr("data-column-id"),
@@ -127,6 +128,7 @@ Board.prototype.dragAndDrop = function() {
);
},
start: function(event, ui) {
ui.item.addClass("draggable-item-selected");
ui.placeholder.height(ui.item.height());
}
});
@@ -225,7 +227,6 @@ Board.prototype.hideColumn = function(columnId) {
$(".board-column-" + columnId + " .board-rotation").each(function() {
var position = $(".board-swimlane").position();
// $(".board-column-task-collapsed").height($(window).height() - position.top);
$(this).css("width", $(".board-column-" + columnId + "").height());
});

View File

@@ -268,6 +268,7 @@ Gantt.prototype.listenForBlockResize = function(startDate) {
jQuery("div.ganttview-block", this.options.container).resizable({
grid: this.options.cellWidth,
handles: "e,w",
delay: $.support.touch ? 1500 : 300,
stop: function() {
var block = jQuery(this);
self.updateDataAndPosition(block, startDate);
@@ -282,6 +283,7 @@ Gantt.prototype.listenForBlockMove = function(startDate) {
jQuery("div.ganttview-block", this.options.container).draggable({
axis: "x",
delay: $.support.touch ? 1500 : 300,
grid: [this.options.cellWidth, this.options.cellWidth],
stop: function() {
var block = jQuery(this);

View File

@@ -0,0 +1,11 @@
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 20112014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);