From c50e137b2e37e54011a87e2740df9f0cd14623ae Mon Sep 17 00:00:00 2001 From: Sebastien Dumetz Date: Mon, 2 Jun 2014 11:49:20 +0200 Subject: [PATCH 1/5] fixed getPointer & drag functions for touch screen getPointer and drag were not setting position when using a touch device. This quick fix may not work properly when using multitouch but I didn't saw any problem on chrome emulation and on my phone. There is multiple ways to get the touch event's position and I might not use the best one. Maybe someone with experience in the matter could improve this solution? --- source/js/jquery-sortable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/js/jquery-sortable.js b/source/js/jquery-sortable.js index 5fcccf3..b473cfd 100644 --- a/source/js/jquery-sortable.js +++ b/source/js/jquery-sortable.js @@ -268,8 +268,8 @@ groupDefaults.onDrag, e) - var x = e.pageX || e.originalEvent.pageX, - y = e.pageY || e.originalEvent.pageY, + var x = e.pageX || e.originalEvent.targetTouches[0].pageX, + y = e.pageY || e.originalEvent.targetTouches[0].pageY, box = this.sameResultBox, t = this.options.tolerance @@ -390,8 +390,8 @@ }, getPointer: function(e) { return { - left: e.pageX || e.originalEvent.pageX, - top: e.pageY || e.originalEvent.pageY + left: e.pageX || e.originalEvent.targetTouches[0].pageX, + top: e.pageY || e.originalEvent.targetTouches[0].pageY } }, setupDelayTimer: function () { From 8e5fd309552de0738f271b0f5e2718180ffcc121 Mon Sep 17 00:00:00 2001 From: Sebastien Dumetz Date: Mon, 2 Jun 2014 12:11:46 +0200 Subject: [PATCH 2/5] isValidDrag should ignore "tap" events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit detect ̀ ``touchmove``` instead of `̀``touchstart``` event. This way we ignore simple "taps" on screen, meant to use links, etc... --- source/js/jquery-sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/js/jquery-sortable.js b/source/js/jquery-sortable.js index 5fcccf3..f8fc6e6 100644 --- a/source/js/jquery-sortable.js +++ b/source/js/jquery-sortable.js @@ -472,7 +472,7 @@ }, isValidDrag: function(e) { return e.which == 1 || - e.type == "touchstart" && e.originalEvent.touches.length == 1 + e.type == "touchmove" && e.originalEvent.touches.length == 1 }, searchValidTarget: function (pointer, lastPointer) { var distances = sortByDistanceDesc(this.getItemDimensions(), From 5a859df200d006a765881277b4834ac9d412e90e Mon Sep 17 00:00:00 2001 From: Sebastien Dumetz Date: Mon, 2 Jun 2014 14:35:46 +0200 Subject: [PATCH 3/5] added the middleman command to start dev version --- README.mkd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.mkd b/README.mkd index b5e9052..0463882 100644 --- a/README.mkd +++ b/README.mkd @@ -16,3 +16,5 @@ jquery (>= 1.7.0) jQuery Sortable is developed using [middleman](http://middlemanapp.com/). A **bundle install** shoud pull in everything needed. + bundle exec middleman server +This will start a local web server running at: http://localhost:4567/ From c05f7afa31583dc288d8dbb5b3bc57f1469788ea Mon Sep 17 00:00:00 2001 From: Sebastien Dumetz Date: Mon, 2 Jun 2014 14:43:31 +0200 Subject: [PATCH 4/5] gitignored rvm files --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cbaf437..25e1043 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,8 @@ /.sass-cache /build /.bundle - +.ruby-gemset +.ruby-version # tempfiles *[~#] From d2c27f34a44660a7fad7dd2910fbd7512d846afb Mon Sep 17 00:00:00 2001 From: Sebastien Dumetz Date: Mon, 2 Jun 2014 14:48:40 +0200 Subject: [PATCH 5/5] registered touchmove as event for drag detection --- source/js/jquery-sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/js/jquery-sortable.js b/source/js/jquery-sortable.js index f06e3c2..7a7b3fd 100644 --- a/source/js/jquery-sortable.js +++ b/source/js/jquery-sortable.js @@ -141,7 +141,7 @@ right:0 }, eventNames = { - start: "touchstart.sortable mousedown.sortable", + start: "touchmove.sortable mousedown.sortable", drop: "touchend.sortable touchcancel.sortable mouseup.sortable", drag: "touchmove.sortable mousemove.sortable", scroll: "scroll.sortable"