Browse Source

* fixed touch & 'empty list'

pull/10/head
RubaXa 11 years ago
parent
commit
3aac111143
  1. 20
      Sortable.js
  2. 4
      Sortable.min.js
  3. 2
      package.json

20
Sortable.js

@ -123,7 +123,7 @@
target = _closest(target, options.draggable, el); target = _closest(target, options.draggable, el);
if( target && !dragEl && (target !== el) ){ if( target && !dragEl && (target.parentNode === el) ){
tapEvt = evt; tapEvt = evt;
target.draggable = true; target.draggable = true;
@ -175,7 +175,6 @@
do { do {
if( parent[expando] === group ){ if( parent[expando] === group ){
while( i-- ){ while( i-- ){
touchDragOverListeners[i]({ touchDragOverListeners[i]({
clientX: touchEvt.clientX, clientX: touchEvt.clientX,
@ -186,6 +185,8 @@
} }
break; break;
} }
target = parent; // store last element
} }
while( parent = parent.parentNode ); while( parent = parent.parentNode );
@ -247,7 +248,7 @@
_on(document, 'touchmove', this._onTouchMove); _on(document, 'touchmove', this._onTouchMove);
_on(document, 'touchend', this._onDrop); _on(document, 'touchend', this._onDrop);
this._loopId = setInterval(this._emulateDragOver, 200); this._loopId = setInterval(this._emulateDragOver, 150);
} }
else { else {
dataTransfer.effectAllowed = 'move'; dataTransfer.effectAllowed = 'move';
@ -261,17 +262,16 @@
_onDragOver: function (evt){ _onDragOver: function (evt){
if( !_silent && activeGroup === this.options.group && (evt.rootEl === void 0 || evt.rootEl === this.el) ){ if( !_silent && (activeGroup === this.options.group) && (evt.rootEl === void 0 || evt.rootEl === this.el) ){
var var
el = this.el el = this.el
, target = _closest(evt.target, this.options.draggable, el) , target = _closest(evt.target, this.options.draggable, el)
; ;
if( !target || target[expando] === void 0 ){ if( el.children.length === 0 || el.children[0] === ghostEl ){
if( el.children.length === 0 ){
el.appendChild(dragEl); el.appendChild(dragEl);
} }
else if( target && target !== dragEl ){ else if( target && target !== dragEl && (target.parentNode[expando] !== void 0) ){
if( lastEl !== target ){ if( lastEl !== target ){
lastEl = target; lastEl = target;
lastCSS = _css(target) lastCSS = _css(target)
@ -284,8 +284,8 @@
, height = rect.bottom - rect.top , height = rect.bottom - rect.top
, floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) , floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display)
, skew = (floating ? (evt.clientX - rect.left)/width : (evt.clientY - rect.top)/height) > .5 , skew = (floating ? (evt.clientX - rect.left)/width : (evt.clientY - rect.top)/height) > .5
, isLong = (target.offsetHeight > dragEl.offsetHeight)
, isWide = (target.offsetWidth > dragEl.offsetWidth) , isWide = (target.offsetWidth > dragEl.offsetWidth)
, isLong = (target.offsetHeight > dragEl.offsetHeight)
, nextSibling = target.nextSibling , nextSibling = target.nextSibling
, after , after
; ;
@ -306,7 +306,6 @@
} }
} }
} }
}
}, },
@ -347,7 +346,6 @@
} }
} }
// Set NULL // Set NULL
rootEl = rootEl =
dragEl = dragEl =
@ -503,7 +501,7 @@
}; };
Sortable.version = '0.1.4'; Sortable.version = '0.1.5';
// Export // Export
return Sortable; return Sortable;

4
Sortable.min.js vendored

File diff suppressed because one or more lines are too long

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "sortable", "name": "sortable",
"exportName": "Sortable", "exportName": "Sortable",
"version": "0.1.4", "version": "0.1.5",
"devDependencies": { "devDependencies": {
"grunt": "*", "grunt": "*",
"grunt-version": "*", "grunt-version": "*",

Loading…
Cancel
Save