Browse Source

v0.1.7: #24

pull/29/head 0.1.8
RubaXa 11 years ago
parent
commit
2844979a61
  1. 24
      Sortable.js
  2. 4
      Sortable.min.js
  3. 2
      bower.json
  4. 2
      package.json

24
Sortable.js

@ -28,6 +28,7 @@
, lastEl , lastEl
, lastCSS , lastCSS
, lastRect
, activeGroup , activeGroup
@ -69,7 +70,7 @@
// Defaults // Defaults
options.group = options.group || Math.random(); options.group = options.group || Math.random();
options.handle = options.handle || null; options.handle = options.handle || null;
options.draggable = options.draggable || el.children[0] && el.children[0].nodeName || 'li'; options.draggable = options.draggable || el.children[0] && el.children[0].nodeName || (/[uo]l/i.test(el.nodeName) ? 'li' : '*');
options.ghostClass = options.ghostClass || 'sortable-ghost'; options.ghostClass = options.ghostClass || 'sortable-ghost';
options.onAdd = _bind(this, options.onAdd || noop); options.onAdd = _bind(this, options.onAdd || noop);
@ -159,7 +160,6 @@
_on(this.el, 'dragstart', this._onDragStart); _on(this.el, 'dragstart', this._onDragStart);
_on(this.el, 'dragend', this._onDrop); _on(this.el, 'dragend', this._onDrop);
_on(document, 'dragover', _globalDragOver); _on(document, 'dragover', _globalDragOver);
@ -280,18 +280,19 @@
, target = _closest(evt.target, this.options.draggable, el) , target = _closest(evt.target, this.options.draggable, el)
; ;
if( el.children.length === 0 || el.children[0] === ghostEl ){ if( el.children.length === 0 || el.children[0] === ghostEl || (el === evt.target) && _ghostInBottom(el, evt) ){
el.appendChild(dragEl); el.appendChild(dragEl);
} }
else if( target && target !== dragEl && (target.parentNode[expando] !== void 0) ){ 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);
lastRect = target.getBoundingClientRect();
} }
var var
rect = target.getBoundingClientRect() rect = lastRect
, width = rect.right - rect.left , width = rect.right - rect.left
, 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)
@ -414,7 +415,10 @@
function _closest(el, selector, ctx){ function _closest(el, selector, ctx){
if( el ){ if( selector === '*' ){
return el;
}
else if( el ){
ctx = ctx || document; ctx = ctx || document;
selector = selector.split('.'); selector = selector.split('.');
@ -508,6 +512,12 @@
} }
function _ghostInBottom(el, evt){
var last = el.lastElementChild.getBoundingClientRect();
return evt.clientY - (last.top + last.height) > 5; // min delta
}
// Export utils // Export utils
Sortable.utils = { Sortable.utils = {
@ -521,7 +531,7 @@
}; };
Sortable.version = '0.1.6'; Sortable.version = '0.1.8';
// Export // Export
return Sortable; return Sortable;

4
Sortable.min.js vendored

File diff suppressed because one or more lines are too long

2
bower.json

@ -1,7 +1,7 @@
{ {
"name": "Sortable", "name": "Sortable",
"main": "Sortable.js", "main": "Sortable.js",
"version": "0.1.6", "version": "0.1.8",
"homepage": "http://rubaxa.github.io/Sortable/", "homepage": "http://rubaxa.github.io/Sortable/",
"authors": [ "authors": [
"RubaXa <ibnRubaXa@gmail.com>" "RubaXa <ibnRubaXa@gmail.com>"

2
package.json

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

Loading…
Cancel
Save