Skip to content

Commit 6ab8627

Browse files
Jonas von AndrianJonas von Andrian
authored andcommitted
Fix mobile chrome behavior
closes johnny#130, johnny#139
1 parent 786ebb5 commit 6ab8627

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

source/js/jquery-sortable.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060
delay: 0,
6161
// The css selector of the drag handle
6262
handle: "",
63-
// The exact css path between the item and its subcontainers
63+
// The exact css path between the item and its subcontainers.
64+
// It should only match the immediate items of a container.
65+
// No item of a subcontainer should be matched. E.g. for ol>div>li the itemPath is "> div"
6466
itemPath: "",
6567
// The css selector of the items
6668
itemSelector: "li",
@@ -274,12 +276,11 @@
274276
groupDefaults.onDrag,
275277
e)
276278

277-
var x = e.pageX || e.originalEvent.pageX,
278-
y = e.pageY || e.originalEvent.pageY,
279+
var p = this.getPointer(e),
279280
box = this.sameResultBox,
280281
t = this.options.tolerance
281282

282-
if(!box || box.top - t > y || box.bottom + t < y || box.left - t > x || box.right + t < x)
283+
if(!box || box.top - t > p.top || box.bottom + t < p.top || box.left - t > p.left || box.right + t < p.left)
283284
if(!this.searchValidTarget()){
284285
this.placeholder.detach()
285286
this.lastAppendedItem = undefined
@@ -399,8 +400,8 @@
399400
},
400401
getPointer: function(e) {
401402
return {
402-
left: e.pageX || e.originalEvent.pageX,
403-
top: e.pageY || e.originalEvent.pageY
403+
left: e.pageX || e.originalEvent.pageX || e.originalEvent.touches[0].pageX,
404+
top: e.pageY || e.originalEvent.pageY || e.originalEvent.touches[0].pageY
404405
}
405406
},
406407
setupDelayTimer: function () {

0 commit comments

Comments
 (0)