Skip to content

Commit ccd7d58

Browse files
committed
make mouse events available in configurable event handlers
closes johnny#36
1 parent 6e6f14b commit ccd7d58

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

source/js/jquery-sortable.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@
6767
},
6868
// Executed before onDrop if placeholder is detached.
6969
// This happens if pullPlaceholder is set to false and the drop occurs outside a container.
70-
onCancel: function ($item, container, _super) {
70+
onCancel: function ($item, container, _super, event) {
7171
},
7272
// Executed at the beginning of a mouse move event.
7373
// The Placeholder has not been moved yet.
74-
onDrag: function ($item, position, _super) {
74+
onDrag: function ($item, position, _super, event) {
7575
$item.css(position)
7676
},
7777
// Called after the drag has been started,
7878
// that is the mouse button is beeing held down and
7979
// the mouse is moving.
8080
// The container is the closest initialized container.
8181
// Therefore it might not be the container, that actually contains the item.
82-
onDragStart: function ($item, container, _super) {
82+
onDragStart: function ($item, container, _super, event) {
8383
$item.css({
8484
height: $item.height(),
8585
width: $item.width()
@@ -88,12 +88,12 @@
8888
$("body").addClass("dragging")
8989
},
9090
// Called when the mouse button is beeing released
91-
onDrop: function ($item, container, _super) {
91+
onDrop: function ($item, container, _super, event) {
9292
$item.removeClass("dragged").removeAttr("style")
9393
$("body").removeClass("dragging")
9494
},
9595
// Called on mousedown.
96-
onMousedown: function($item, event, _super) {
96+
onMousedown: function($item, _super, event) {
9797
event.preventDefault()
9898
},
9999
// Template for the placeholder. Can be any valid jQuery input
@@ -234,7 +234,7 @@
234234

235235
this.setPointer(e)
236236

237-
this.options.onMousedown(this.item, e, groupDefaults.onMousedown)
237+
this.options.onMousedown(this.item, groupDefaults.onMousedown, e)
238238
} else {
239239
this.toggleListeners('on', ['drop'])
240240
}
@@ -246,7 +246,7 @@
246246
if(!this.distanceMet(e))
247247
return
248248

249-
this.options.onDragStart(this.item, this.itemContainer, groupDefaults.onDragStart)
249+
this.options.onDragStart(this.item, this.itemContainer, groupDefaults.onDragStart, e)
250250
this.item.before(this.placeholder)
251251
this.dragging = true
252252
}
@@ -255,7 +255,8 @@
255255
// place item under the cursor
256256
this.options.onDrag(this.item,
257257
getRelativePosition(this.pointer, this.item.offsetParent()),
258-
groupDefaults.onDrag)
258+
groupDefaults.onDrag,
259+
e)
259260

260261
var x = e.pageX,
261262
y = e.pageY,
@@ -276,9 +277,9 @@
276277
if(this.placeholder.closest("html")[0])
277278
this.placeholder.before(this.item).detach()
278279
else
279-
this.options.onCancel(this.item, this.itemContainer, groupDefaults.onCancel)
280+
this.options.onCancel(this.item, this.itemContainer, groupDefaults.onCancel, e)
280281

281-
this.options.onDrop(this.item, this.getContainer(this.item), groupDefaults.onDrop)
282+
this.options.onDrop(this.item, this.getContainer(this.item), groupDefaults.onDrop, e)
282283

283284
// cleanup
284285
this.clearDimensions()

0 commit comments

Comments
 (0)