Permalink
Browse files

additional option: onMousedown

closes #17
  • Loading branch information...
1 parent 10e8bd2 commit 7069e8fefc2f4e597257c2d00433698c1aa4b694 @johnny committed May 18, 2013
Showing with 12 additions and 9 deletions.
  1. +12 −9 source/js/jquery-sortable.js
@@ -66,7 +66,7 @@
onCancel: function ($item, container, _super) {
},
// Executed at the beginning of a mouse move event.
- // The Placeholder has not been moved yet
+ // The Placeholder has not been moved yet.
onDrag: function ($item, position, _super) {
$item.css(position)
},
@@ -88,6 +88,10 @@
$item.removeClass("dragged").removeAttr("style")
$("body").removeClass("dragging")
},
+ // Called on mousedown.
+ onMousedown: function($item, event, _super) {
+ event.preventDefault()
+ },
// Template for the placeholder. Can be any valid jQuery input
// e.g. a string, a DOM element
placeholder: '<li class="placeholder"/>',
@@ -241,6 +245,8 @@
this.itemContainer = itemContainer
this.setPointer(e)
+
+ this.options.onMousedown(this.item, e, groupDefaults.onMousedown)
},
drag: function (e) {
if(!this.dragging){
@@ -431,15 +437,12 @@
Container.prototype = {
dragInit: function (e) {
var rootGroup = this.rootGroup
- if(rootGroup.item ||
- e.which !== 1 ||
- !this.options.drag ||
- $(e.target).is(this.options.exclude))
- return;
-
- e.preventDefault()
- rootGroup.dragInit(e, this)
+ if( !rootGroup.item &&
+ e.which === 1 &&
+ this.options.drag &&
+ !$(e.target).is(this.options.exclude))
+ rootGroup.dragInit(e, this)
},
searchValidTarget: function (pointer, lastPointer) {
var distances = sortByDistanceDesc(this.getItemDimensions(),

0 comments on commit 7069e8f

Please sign in to comment.