Browse Source

react handleMove/onMove event

modified the private _onMove prototype, so it calls events on it's
source Element like it's sibling function _dispatchEvent
added the handleMove, which listens to the onMove events to the react
mixin
pull/441/head
ChiefORZ 10 years ago
parent
commit
5d6747a9c7
  1. 20
      Sortable.js
  2. 5
      react-sortable-mixin.js

20
Sortable.js

@ -1021,17 +1021,19 @@
onMoveFn = sortable.options.onMove, onMoveFn = sortable.options.onMove,
retVal; retVal;
if (onMoveFn) { evt = document.createEvent('Event');
evt = document.createEvent('Event'); evt.initEvent('move', true, true);
evt.initEvent('move', true, true);
evt.to = toEl;
evt.from = fromEl;
evt.dragged = dragEl;
evt.draggedRect = dragRect;
evt.related = targetEl || toEl;
evt.relatedRect = targetRect || toEl.getBoundingClientRect();
evt.to = toEl; fromEl.dispatchEvent(evt);
evt.from = fromEl;
evt.dragged = dragEl;
evt.draggedRect = dragRect;
evt.related = targetEl || toEl;
evt.relatedRect = targetRect || toEl.getBoundingClientRect();
if (onMoveFn) {
retVal = onMoveFn.call(sortable, evt); retVal = onMoveFn.call(sortable, evt);
} }

5
react-sortable-mixin.js vendored

@ -34,7 +34,8 @@
onUpdate: 'handleUpdate', onUpdate: 'handleUpdate',
onRemove: 'handleRemove', onRemove: 'handleRemove',
onSort: 'handleSort', onSort: 'handleSort',
onFilter: 'handleFilter' onFilter: 'handleFilter',
onMove: 'handleMove'
}; };
@ -90,7 +91,7 @@
// Bind callbacks so that "this" refers to the component // Bind callbacks so that "this" refers to the component
'onStart onEnd onAdd onSort onUpdate onRemove onFilter'.split(' ').forEach(function (/** string */name) { 'onStart onEnd onAdd onSort onUpdate onRemove onFilter onMove'.split(' ').forEach(function (/** string */name) {
copyOptions[name] = function (evt) { copyOptions[name] = function (evt) {
if (name === 'onStart') { if (name === 'onStart') {
_nextSibling = evt.item.nextElementSibling; _nextSibling = evt.item.nextElementSibling;

Loading…
Cancel
Save