Skip to content

Commit b831dac

Browse files
committed
Update pages. See main branch for changes
1 parent ddc283d commit b831dac

File tree

6 files changed

+97
-37
lines changed

6 files changed

+97
-37
lines changed

index.html

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ <h1>jQuery Sortable</h1>
7171
<a class='btn btn-large btn-success' href='js/jquery-sortable.js'>
7272
<i class='icon-hdd icon-white'></i>
7373
Download
74-
(v0.9.8)
74+
(v0.9.9)
7575
</a>
7676
</p>
7777
<p>
7878
<small>
7979
Download
8080
<a href='js/jquery-sortable-min.js'>minified</a>
8181
version
82-
(8.2 kb, gzipped ~2.7 kb)
82+
(8.4 kb, gzipped ~2.8 kb)
8383
</small>
8484
</p>
8585
</div>
@@ -580,7 +580,9 @@ <h2>Connected lists with limited drop targets</h2>
580580
},
581581
<span class="function">serialize</span>: <span class="keyword">function</span> (parent, children, isContainer) {
582582
<span class="keyword">return</span> isContainer ? children.join() : parent.text()
583-
}
583+
},
584+
<span class="key">tolerance</span>: <span class="integer">6</span>,
585+
<span class="key">distance</span>: <span class="integer">10</span>
584586
})</pre></div>
585587
</div>
586588

@@ -596,6 +598,15 @@ <h2>Connected lists with limited drop targets</h2>
596598
<strong>serialization</strong>
597599
of the lists
598600
</li>
601+
<li>
602+
Decrease sort
603+
<strong>sensitivity</strong>
604+
</li>
605+
<li>
606+
Start dragging after a
607+
<strong>distance</strong>
608+
has been met
609+
</li>
599610
</ul>
600611
<p><div class="btn btn-primary show-code" data-toggle="button"><i class="icon-chevron-down"></i> show me the code</div></p>
601612
<h3>Serialize result</h3>
@@ -964,6 +975,16 @@ <h2 id='group-options'>Group options</h2>
964975

965976
</td>
966977
<td> The css selector of the containers</td>
978+
</tr><tr><td>
979+
<code>distance</code>
980+
</td>
981+
<td>
982+
<div class="CodeRay">
983+
<div class="code"><pre><span class="integer">0</span></pre></div>
984+
</div>
985+
986+
</td>
987+
<td> Distance the mouse has to travel to start dragging</td>
967988
</tr><tr><td>
968989
<code>handle</code>
969990
</td>
@@ -1042,7 +1063,7 @@ <h2 id='group-options'>Group options</h2>
10421063
<td>
10431064
<div class="CodeRay">
10441065
<div class="code"><pre><span class="keyword">function</span> (<span class="predefined">$item</span>, container, _super) {
1045-
<span class="predefined">$item</span>.removeClass(<span class="string"><span class="delimiter">&quot;</span><span class="content">dragged</span><span class="delimiter">&quot;</span></span>).attr(<span class="string"><span class="delimiter">&quot;</span><span class="content">style</span><span class="delimiter">&quot;</span></span>,<span class="string"><span class="delimiter">&quot;</span><span class="delimiter">&quot;</span></span>)
1066+
<span class="predefined">$item</span>.removeClass(<span class="string"><span class="delimiter">&quot;</span><span class="content">dragged</span><span class="delimiter">&quot;</span></span>).removeAttr(<span class="string"><span class="delimiter">&quot;</span><span class="content">style</span><span class="delimiter">&quot;</span></span>)
10461067
<span class="predefined">$</span>(<span class="string"><span class="delimiter">&quot;</span><span class="content">body</span><span class="delimiter">&quot;</span></span>).removeClass(<span class="string"><span class="delimiter">&quot;</span><span class="content">dragging</span><span class="delimiter">&quot;</span></span>)
10471068
}</pre></div>
10481069
</div>
@@ -1085,6 +1106,16 @@ <h2 id='group-options'>Group options</h2>
10851106

10861107
</td>
10871108
<td> Specifies serialization of the container group. The pair $parent/$children is either container/items or item/subcontainers</td>
1109+
</tr><tr><td>
1110+
<code>tolerance</code>
1111+
</td>
1112+
<td>
1113+
<div class="CodeRay">
1114+
<div class="code"><pre><span class="integer">0</span></pre></div>
1115+
</div>
1116+
1117+
</td>
1118+
<td> Set tolerance while dragging. Positive values will decrease sensitivity.</td>
10881119
</tr>
10891120
</tbody>
10901121
</table>

js/application.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ colors = jQuery.Color.names = {
10821082

10831083
}(window.jQuery);
10841084
/* ===================================================
1085-
* jquery-sortable.js v0.9.8
1085+
* jquery-sortable.js v0.9.9
10861086
* http://johnny.github.com/jquery-sortable/
10871087
* ===================================================
10881088
* Copyright (c) 2012 Jonas von Andrian
@@ -1133,6 +1133,8 @@ colors = jQuery.Color.names = {
11331133
},
11341134
// The css selector of the containers
11351135
containerSelector: "ol, ul",
1136+
// Distance the mouse has to travel to start dragging
1137+
distance: 0,
11361138
// The css selector of the drag handle
11371139
handle: "",
11381140
// The css selector of the items
@@ -1167,7 +1169,7 @@ colors = jQuery.Color.names = {
11671169
},
11681170
// Called when the mouse button is beeing released
11691171
onDrop: function ($item, container, _super) {
1170-
$item.removeClass("dragged").attr("style","")
1172+
$item.removeClass("dragged").removeAttr("style")
11711173
$("body").removeClass("dragging")
11721174
},
11731175
// Template for the placeholder. Can be any valid jQuery input
@@ -1186,7 +1188,9 @@ colors = jQuery.Color.names = {
11861188
delete result.sortable
11871189

11881190
return result
1189-
}
1191+
},
1192+
// Set tolerance while dragging. Positive values will decrease sensitivity.
1193+
tolerance: 0
11901194
}, // end group defaults
11911195
containerGroups = {},
11921196
groupCounter = 0
@@ -1320,25 +1324,28 @@ colors = jQuery.Color.names = {
13201324
e.preventDefault()
13211325

13221326
if(!this.dragging){
1327+
if(!this.distanceMet(e))
1328+
return
1329+
13231330
processChildContainers(this.item, this.options.containerSelector, "disable", true)
13241331

13251332
this.options.onDragStart(this.item, this.itemContainer, groupDefaults.onDragStart)
13261333
this.item.before(this.placeholder)
13271334
this.dragging = true
13281335
}
13291336

1330-
if(!this.setPointer(e))
1331-
return;
1332-
1337+
this.setPointer(e)
13331338
// place item under the cursor
13341339
this.options.onDrag(this.item,
13351340
getRelativePosition(this.pointer, this.item.offsetParent()),
13361341
groupDefaults.onDrag)
13371342

13381343
var x = e.pageX,
13391344
y = e.pageY,
1340-
box = this.sameResultBox
1341-
if(!box || box.top > y || box.bottom < y || box.left > x || box.right < x)
1345+
box = this.sameResultBox,
1346+
t = this.options.tolerance
1347+
1348+
if(!box || box.top - t > y || box.bottom + t < y || box.left - t > x || box.right + t < x)
13421349
if(!this.searchValidTarget())
13431350
this.placeholder.detach()
13441351
},
@@ -1449,7 +1456,12 @@ colors = jQuery.Color.names = {
14491456

14501457
this.lastPointer = this.pointer
14511458
this.pointer = pointer
1452-
return true
1459+
},
1460+
distanceMet: function (e) {
1461+
return (Math.max(
1462+
Math.abs(this.pointer.left - e.pageX),
1463+
Math.abs(this.pointer.top - e.pageY)
1464+
) >= this.options.distance)
14531465
},
14541466
addContainer: function (container) {
14551467
this.containers.push(container);
@@ -1687,7 +1699,9 @@ $(function () {
16871699
},
16881700
serialize: function (parent, children, isContainer) {
16891701
return isContainer ? children.join() : parent.text()
1690-
}
1702+
},
1703+
tolerance: 6,
1704+
distance: 10
16911705
})
16921706
})
16931707
;

js/examples/limited_drop_targets.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ $(function () {
1414
},
1515
serialize: function (parent, children, isContainer) {
1616
return isContainer ? children.join() : parent.text()
17-
}
17+
},
18+
tolerance: 6,
19+
distance: 10
1820
})
1921
})
2022
;

0 commit comments

Comments
 (0)