Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: johnny/jquery-sortable
base: 354e9e3b7c
...
head fork: johnny/jquery-sortable
compare: c77bafd325
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 03, 2014
Kosta Korenkov troggy Ability to specify certain delay before drag start to be captured #64 f5387c1
Commits on Feb 19, 2014
Jonas von Andrian some polish c77bafd
Showing with 20 additions and 1 deletion.
  1. +3 −0  TODO
  2. +17 −1 source/js/jquery-sortable.js
3  TODO
View
@@ -1,6 +1,9 @@
+- [0/1] exampels
+ - [ ] delay
- [0/2] bugs
- [ ] last Pointer is NaN in search valid target
- [ ] prevent infinite recursion
+ - [ ] bootstrap example jumps up on drop
- [0/5] consider
- [ ] better name for searchValidTarget
- [ ] shortcut on getNearest()
18 source/js/jquery-sortable.js
View
@@ -56,6 +56,9 @@
containerSelector: "ol, ul",
// Distance the mouse has to travel to start dragging
distance: 0,
+ // Time in milliseconds after mousedown until dragging should start.
+ // This option can be used to prevent unwanted drags when clicking on an element.
+ delay: 0,
// The css selector of the drag handle
handle: "",
// The exact css path between the item and its subcontainers
@@ -246,11 +249,12 @@
this.toggleListeners('on', ['drop'])
}
+ this.setupDelayTimer()
this.dragInitDone = true
},
drag: function (e) {
if(!this.dragging){
- if(!this.distanceMet(e))
+ if(!this.distanceMet(e) || !this.delayMet)
return
this.options.onDragStart(this.item, this.itemContainer, groupDefaults.onDragStart, e)
@@ -387,6 +391,18 @@
Math.abs(this.pointer.top - e.pageY)
) >= this.options.distance)
},
+ setupDelayTimer: function () {
+ var that = this
+ this.delayMet = !this.options.delay
+
+ // init delay timer if needed
+ if (!this.delayMet) {
+ clearTimeout(this._mouseDelayTimer);
+ this._mouseDelayTimer = setTimeout(function() {
+ that.delayMet = true
+ }, this.options.delay)
+ }
+ },
scroll: function (e) {
this.clearDimensions()
this.clearOffsetParent()

No commit comments for this range

Something went wrong with that request. Please try again.