diff --git a/Sortable.js b/Sortable.js index 315b21f..f70723e 100644 --- a/Sortable.js +++ b/Sortable.js @@ -465,13 +465,10 @@ target = _closest(evt.target, options.draggable, el); dragRect = dragEl.getBoundingClientRect(); - if (cloneEl && (cloneEl.state !== isOwner)) { - _css(cloneEl, 'display', isOwner ? 'none' : ''); - !isOwner && cloneEl.state && rootEl.insertBefore(cloneEl, dragEl); - cloneEl.state = isOwner; - } if (revert) { + _cloneHide(true); + if (cloneEl || nextEl) { rootEl.insertBefore(dragEl, cloneEl || nextEl); } @@ -482,6 +479,7 @@ return; } + if ((el.children.length === 0) || (el.children[0] === ghostEl) || (el === evt.target) && (target = _ghostInBottom(el, evt)) ) { @@ -492,6 +490,8 @@ targetRect = target.getBoundingClientRect(); } + _cloneHide(isOwner); + el.appendChild(dragEl); this._animate(dragRect, dragEl); target && this._animate(targetRect, target); @@ -517,6 +517,8 @@ _silent = true; setTimeout(_unsilent, 30); + _cloneHide(isOwner); + if (floating) { after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide; } else { @@ -760,6 +762,15 @@ }; + function _cloneHide(state) { + if (cloneEl && (cloneEl.state !== state)) { + _css(cloneEl, 'display', state ? 'none' : ''); + !state && cloneEl.state && rootEl.insertBefore(cloneEl, dragEl); + cloneEl.state = state; + } + } + + function _bind(ctx, fn) { var args = slice.call(arguments, 2); return fn.bind ? fn.bind.apply(fn, [ctx].concat(args)) : function () { @@ -953,7 +964,7 @@ }; - Sortable.version = '0.7.2'; + Sortable.version = '0.7.3'; /** diff --git a/Sortable.min.js b/Sortable.min.js index 8815673..93fe93b 100644 --- a/Sortable.min.js +++ b/Sortable.min.js @@ -1,2 +1,2 @@ -/*! Sortable 0.7.2 - MIT | git://github.com/rubaxa/Sortable.git */ -!function(a){"use strict";"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():"undefined"!=typeof Package?Sortable=a():window.Sortable=a()}(function(){"use strict";function a(a,c){this.el=a,this.options=c=c||{};var d={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:a.children[0]&&a.children[0].nodeName||(/[uo]l/i.test(a.nodeName)?"li":"*"),ghostClass:"sortable-ghost",ignore:"a, img",filter:null,animation:0,setData:function(a,b){a.setData("Text",b.textContent)}};for(var f in d)!(f in c)&&(c[f]=d[f]);c.group.name||(c.group={name:c.group}),["pull","put"].forEach(function(a){a in c.group||(c.group[a]=!0)}),J.forEach(function(d){c[d]=b(this,c[d]||K),e(a,d.substr(2).toLowerCase(),c[d])},this),a[C]=c.group.name;for(var g in this)"_"===g.charAt(0)&&(this[g]=b(this,this[g]));e(a,"mousedown",this._onTapStart),e(a,"touchstart",this._onTapStart),G&&e(a,"selectstart",this._onTapStart),e(a,"dragover",this._onDragOver),e(a,"dragenter",this._onDragOver),N.push(this._onDragOver),c.store&&this.sort(c.store.get(this))}function b(a,b){var c=M.call(arguments,2);return b.bind?b.bind.apply(b,[a].concat(c)):function(){return b.apply(a,c.concat(M.call(arguments)))}}function c(a,b,c){if("*"===b)return a;if(a){c=c||E,b=b.split(".");var d=b.shift().toUpperCase(),e=new RegExp("\\s("+b.join("|")+")\\s","g");do if(!(""!==d&&a.nodeName!=d||b.length&&((" "+a.className+" ").match(e)||[]).length!=b.length))return a;while(a!==c&&(a=a.parentNode))}return null}function d(a){a.dataTransfer.dropEffect="move",a.preventDefault()}function e(a,b,c){a.addEventListener(b,c,!1)}function f(a,b,c){a.removeEventListener(b,c,!1)}function g(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(/\s+/g," ").replace(" "+b+" ","");a.className=d+(c?" "+b:"")}}function h(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return E.defaultView&&E.defaultView.getComputedStyle?c=E.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b),d[b]=c+("string"==typeof c?"":"px")}}function i(a,b,c){if(a){var d=a.getElementsByTagName(b),e=0,f=d.length;if(c)for(;f>e;e++)c(d[e],e);return d}return[]}function j(a){a.draggable=!1}function k(){H=!1}function l(a,b){var c=a.lastElementChild,d=c.getBoundingClientRect();return b.clientY-(d.top+d.height)>5&&c}function m(a){for(var b=a.tagName+a.className+a.src+a.href+a.textContent,c=b.length,d=0;c--;)d+=b.charCodeAt(c);return d.toString(36)}function n(a){for(var b=0;a&&(a=a.previousElementSibling);)b++;return b}function o(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,setTimeout(function(){1===c.length?a.call(d,c[0]):a.apply(d,c),c=void 0},b))}}var p,q,r,s,t,u,v,w,x,y,z,A,B={},C="Sortable"+(new Date).getTime(),D=window,E=D.document,F=D.parseInt,G=!!E.createElement("div").dragDrop,H=!1,I=function(a,b,c,d,e,f){var g=E.createEvent("Event");g.initEvent(b,!0,!0),g.item=c||a,g.from=d||a,g.oldIndex=e,g.newIndex=f,a.dispatchEvent(g)},J="onAdd onUpdate onRemove onStart onEnd onFilter onSort".split(" "),K=function(){},L=Math.abs,M=[].slice,N=[];return a.prototype={constructor:a,_applyEffects:function(){g(p,this.options.ghostClass,!0)},_onTapStart:function(a){var b=a.touches&&a.touches[0],d=(b||a).target,f=d,g=this.options,k=this.el,l=g.filter;if(!("mousedown"===a.type&&0!==a.button||g.disabled)){if(g.handle&&(d=c(d,g.handle,k)),d=c(d,g.draggable,k),q=n(d),"function"==typeof l){if(l.call(this,a,d,this))return I(f,"filter",d,k,q),void 0}else if(l&&(l=l.split(",").some(function(a){return a=c(f,a.trim(),k),a?(I(a,"filter",d,k,q),!0):void 0}),l.length))return;if(d&&"selectstart"==a.type&&"A"!=d.tagName&&"IMG"!=d.tagName&&d.dragDrop(),d&&!p&&d.parentNode===k){z=a,t=this.el,p=d,v=p.nextSibling,y=this.options.group,p.draggable=!0,g.ignore.split(",").forEach(function(a){i(d,a.trim(),j)}),b&&(z={target:d,clientX:b.clientX,clientY:b.clientY},this._onDragStart(z,!0),a.preventDefault()),e(E,"mouseup",this._onDrop),e(E,"touchend",this._onDrop),e(E,"touchcancel",this._onDrop),e(t,"dragstart",this._onDragStart),e(t,"dragend",this._onDrop),e(E,"dragover",this);try{E.selection?E.selection.empty():window.getSelection().removeAllRanges()}catch(m){}I(t,"start",p,t,q),"clone"==y.pull&&(s=p.cloneNode(!0),h(s,"display","none"),t.insertBefore(s,p))}}},_emulateDragOver:function(){if(A){h(r,"display","none");var a=E.elementFromPoint(A.clientX,A.clientY),b=a,c=this.options.group.name,d=N.length;if(b)do{if(b[C]===c){for(;d--;)N[d]({clientX:A.clientX,clientY:A.clientY,target:a,rootEl:b});break}a=b}while(b=b.parentNode);h(r,"display","")}},_onTouchMove:function(a){if(z){var b=a.touches[0],c=b.clientX-z.clientX,d=b.clientY-z.clientY,e="translate3d("+c+"px,"+d+"px,0)";A=b,h(r,"webkitTransform",e),h(r,"mozTransform",e),h(r,"msTransform",e),h(r,"transform",e),this._onDrag(b),a.preventDefault()}},_onDragStart:function(a,b){var c=a.dataTransfer,d=this.options;if(this._offUpEvents(),b){var f,g=p.getBoundingClientRect(),i=h(p);r=p.cloneNode(!0),h(r,"top",g.top-F(i.marginTop,10)),h(r,"left",g.left-F(i.marginLeft,10)),h(r,"width",g.width),h(r,"height",g.height),h(r,"opacity","0.8"),h(r,"position","fixed"),h(r,"zIndex","100000"),t.appendChild(r),f=r.getBoundingClientRect(),h(r,"width",2*g.width-f.width),h(r,"height",2*g.height-f.height),e(E,"touchmove",this._onTouchMove),e(E,"touchend",this._onDrop),e(E,"touchcancel",this._onDrop),this._loopId=setInterval(this._emulateDragOver,150)}else c.effectAllowed="move",d.setData&&d.setData.call(this,c,p),e(E,"drop",this);if(setTimeout(this._applyEffects,0),u=d.scroll,u===!0){u=t;do if(u.offsetWidth=i-g)-(e>=g),l=(e>=j-h)-(e>=h);k||l?b=D:u&&(b=u,c=u.getBoundingClientRect(),k=(L(c.right-g)<=e)-(L(c.left-g)<=e),l=(L(c.bottom-h)<=e)-(L(c.top-h)<=e)),(B.vx!==k||B.vy!==l||B.el!==b)&&(B.el=b,B.vx=k,B.vy=l,clearInterval(B.pid),b&&(B.pid=setInterval(function(){b===D?D.scrollTo(D.scrollX+k*f,D.scrollY+l*f):(l&&(b.scrollTop+=l*f),k&&(b.scrollLeft+=k*f))},24)))}},30),_onDragOver:function(a){var b,d,e,f=this.el,g=this.options,i=g.group,j=i.put,m=y===i,n=g.sort;if(!H&&(m?n||(e=!t.contains(p)):y.pull&&j&&(y.name===i.name||j.indexOf&&~j.indexOf(y.name)))&&(void 0===a.rootEl||a.rootEl===this.el)){if(b=c(a.target,g.draggable,f),d=p.getBoundingClientRect(),s&&s.state!==m&&(h(s,"display",m?"none":""),!m&&s.state&&t.insertBefore(s,p),s.state=m),e)return s||v?t.insertBefore(p,s||v):n||t.appendChild(p),void 0;if(0===f.children.length||f.children[0]===r||f===a.target&&(b=l(f,a))){if(b){if(b.animated)return;q=b.getBoundingClientRect()}f.appendChild(p),this._animate(d,p),b&&this._animate(q,b)}else if(b&&!b.animated&&b!==p&&void 0!==b.parentNode[C]){w!==b&&(w=b,x=h(b));var o,q=b.getBoundingClientRect(),u=q.right-q.left,z=q.bottom-q.top,A=/left|right|inline/.test(x.cssFloat+x.display),B=b.offsetWidth>p.offsetWidth,D=b.offsetHeight>p.offsetHeight,E=(A?(a.clientX-q.left)/u:(a.clientY-q.top)/z)>.5,F=b.nextElementSibling;H=!0,setTimeout(k,30),o=A?b.previousElementSibling===p&&!B||E&&B:F!==p&&!D||E&&D,o&&!F?f.appendChild(p):b.parentNode.insertBefore(p,o?F:b),this._animate(d,p),this._animate(q,b)}}},_animate:function(a,b){var c=this.options.animation;if(c){var d=b.getBoundingClientRect();h(b,"transition","none"),h(b,"transform","translate3d("+(a.left-d.left)+"px,"+(a.top-d.top)+"px,0)"),b.offsetWidth,h(b,"transition","all "+c+"ms"),h(b,"transform","translate3d(0,0,0)"),clearTimeout(b.animated),b.animated=setTimeout(function(){h(b,"transition",""),b.animated=!1},c)}},_offUpEvents:function(){f(E,"mouseup",this._onDrop),f(E,"touchmove",this._onTouchMove),f(E,"touchend",this._onDrop),f(E,"touchcancel",this._onDrop)},_onDrop:function(a){var b=this.el;if(clearInterval(this._loopId),clearInterval(B.pid),f(E,"drop",this),f(E,"dragover",this),f(b,"dragend",this._onDrop),f(b,"dragstart",this._onDragStart),this._offUpEvents(),a){if(a.preventDefault(),a.stopPropagation(),r&&r.parentNode.removeChild(r),p){var c=n(p);j(p),g(p,this.options.ghostClass,!1),t.contains(p)?p.nextSibling!==v&&(I(t,"update",p,t,q,c),I(t,"sort",p,t,q,c),s&&s.parentNode.removeChild(s)):(I(p.parentNode,"sort",p,t,q,c),I(t,"sort",p,t,q,c),I(p,"add",p,t,q,c),I(t,"remove",p,t,q,c)),I(t,"end",p,t,q,c)}t=p=r=v=s=z=A=w=x=y=null,this.options.store&&this.options.store.set(this)}},handleEvent:function(a){var b=a.type;"dragover"===b?(this._onDrag(a),d(a)):"drop"===b&&this._onDrop(a)},toArray:function(){for(var a,b=[],d=this.el.children,e=0,f=d.length;f>e;e++)a=d[e],c(a,this.options.draggable,this.el)&&b.push(a.getAttribute("data-id")||m(a));return b},sort:function(a){var b={},d=this.el;this.toArray().forEach(function(a,e){var f=d.children[e];c(f,this.options.draggable,d)&&(b[a]=f)},this),a.forEach(function(a){b[a]&&(d.removeChild(b[a]),d.appendChild(b[a]))})},closest:function(a,b){return c(a,b||this.options.draggable,this.el)},option:function(a,b){var c=this.options;return void 0===b?c[a]:(c[a]=b,void 0)},destroy:function(){var a=this.el,b=this.options;J.forEach(function(c){f(a,c.substr(2).toLowerCase(),b[c])}),f(a,"mousedown",this._onTapStart),f(a,"touchstart",this._onTapStart),f(a,"selectstart",this._onTapStart),f(a,"dragover",this._onDragOver),f(a,"dragenter",this._onDragOver),Array.prototype.forEach.call(a.querySelectorAll("[draggable]"),function(a){a.removeAttribute("draggable")}),N.splice(N.indexOf(this._onDragOver),1),this._onDrop(),this.el=null}},a.utils={on:e,off:f,css:h,find:i,bind:b,is:function(a,b){return!!c(a,b,a)},throttle:o,closest:c,toggleClass:g,dispatchEvent:I,index:n},a.version="0.7.2",a.create=function(b,c){return new a(b,c)},a}); \ No newline at end of file +/*! Sortable 0.7.3 - MIT | git://github.com/rubaxa/Sortable.git */ +!function(a){"use strict";"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():"undefined"!=typeof Package?Sortable=a():window.Sortable=a()}(function(){"use strict";function a(a,b){this.el=a,this.options=b=b||{};var d,e={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(a.nodeName)?"li":">*",ghostClass:"sortable-ghost",ignore:"a, img",filter:null,animation:0,setData:function(a,b){a.setData("Text",b.textContent)}};for(var g in e)!(g in b)&&(b[g]=e[g]);b.group.name||(b.group={name:b.group}),d=b.group,["pull","put"].forEach(function(a){a in d||(d[a]=!0)}),K.forEach(function(d){b[d]=c(this,b[d]||L),f(a,d.substr(2).toLowerCase(),b[d])},this),a[D]=d.name+" "+(d.put.join?d.put.join(" "):"");for(var h in this)"_"===h.charAt(0)&&(this[h]=c(this,this[h]));f(a,"mousedown",this._onTapStart),f(a,"touchstart",this._onTapStart),H&&f(a,"selectstart",this._onTapStart),f(a,"dragover",this._onDragOver),f(a,"dragenter",this._onDragOver),O.push(this._onDragOver),b.store&&this.sort(b.store.get(this))}function b(a){t&&t.state!==a&&(i(t,"display",a?"none":""),!a&&t.state&&u.insertBefore(t,q),t.state=a)}function c(a,b){var c=N.call(arguments,2);return b.bind?b.bind.apply(b,[a].concat(c)):function(){return b.apply(a,c.concat(N.call(arguments)))}}function d(a,b,c){if(a){c=c||F,b=b.split(".");var d=b.shift().toUpperCase(),e=new RegExp("\\s("+b.join("|")+")\\s","g");do if(">*"===d&&a.parentNode===c||(""===d||a.nodeName==d)&&(!b.length||((" "+a.className+" ").match(e)||[]).length==b.length))return a;while(a!==c&&(a=a.parentNode))}return null}function e(a){a.dataTransfer.dropEffect="move",a.preventDefault()}function f(a,b,c){a.addEventListener(b,c,!1)}function g(a,b,c){a.removeEventListener(b,c,!1)}function h(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(/\s+/g," ").replace(" "+b+" ","");a.className=d+(c?" "+b:"")}}function i(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return F.defaultView&&F.defaultView.getComputedStyle?c=F.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b),d[b]=c+("string"==typeof c?"":"px")}}function j(a,b,c){if(a){var d=a.getElementsByTagName(b),e=0,f=d.length;if(c)for(;f>e;e++)c(d[e],e);return d}return[]}function k(a){a.draggable=!1}function l(){I=!1}function m(a,b){var c=a.lastElementChild,d=c.getBoundingClientRect();return b.clientY-(d.top+d.height)>5&&c}function n(a){for(var b=a.tagName+a.className+a.src+a.href+a.textContent,c=b.length,d=0;c--;)d+=b.charCodeAt(c);return d.toString(36)}function o(a){for(var b=0;a&&(a=a.previousElementSibling)&&"TEMPLATE"!==a.nodeName;)b++;return b}function p(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,setTimeout(function(){1===c.length?a.call(d,c[0]):a.apply(d,c),c=void 0},b))}}var q,r,s,t,u,v,w,x,y,z,A,B,C={},D="Sortable"+(new Date).getTime(),E=window,F=E.document,G=E.parseInt,H=!!F.createElement("div").dragDrop,I=!1,J=function(a,b,c,d,e,f){var g=F.createEvent("Event");g.initEvent(b,!0,!0),g.item=c||a,g.from=d||a,g.oldIndex=e,g.newIndex=f,a.dispatchEvent(g)},K="onAdd onUpdate onRemove onStart onEnd onFilter onSort".split(" "),L=function(){},M=Math.abs,N=[].slice,O=[];return a.prototype={constructor:a,_applyEffects:function(){h(q,this.options.ghostClass,!0)},_onTapStart:function(b){var c=b.touches&&b.touches[0],e=(c||b).target,g=e,h=this.options,l=this.el,m=h.filter;if(!("mousedown"===b.type&&0!==b.button||h.disabled)){if(h.handle&&(e=d(e,h.handle,l)),e=d(e,h.draggable,l),r=o(e),"function"==typeof m){if(m.call(this,b,e,this))return J(g,"filter",e,l,r),b.preventDefault(),void 0}else if(m&&(m=m.split(",").some(function(a){return a=d(g,a.trim(),l),a?(J(a,"filter",e,l,r),!0):void 0})))return b.preventDefault(),void 0;if(e&&"selectstart"==b.type&&"A"!=e.tagName&&"IMG"!=e.tagName&&e.dragDrop(),e&&!q&&e.parentNode===l){A=b,u=this.el,q=e,w=q.nextSibling,z=this.options.group,q.draggable=!0,h.ignore.split(",").forEach(function(a){j(e,a.trim(),k)}),c&&(A={target:e,clientX:c.clientX,clientY:c.clientY},this._onDragStart(A,!0),b.preventDefault()),f(F,"mouseup",this._onDrop),f(F,"touchend",this._onDrop),f(F,"touchcancel",this._onDrop),f(q,"dragend",this),f(u,"dragstart",this._onDragStart),f(F,"dragover",this);try{F.selection?F.selection.empty():window.getSelection().removeAllRanges()}catch(n){}J(u,"start",q,u,r),"clone"==z.pull&&(t=q.cloneNode(!0),i(t,"display","none"),u.insertBefore(t,q)),a.active=this}}},_emulateDragOver:function(){if(B){i(s,"display","none");var a=F.elementFromPoint(B.clientX,B.clientY),b=a.parentNode,c=this.options.group.name,d=O.length;if(b&&(" "+b[D]+" ").indexOf(c)>-1)for(;d--;)O[d]({clientX:B.clientX,clientY:B.clientY,target:a,rootEl:b});i(s,"display","")}},_onTouchMove:function(a){if(A){var b=a.touches[0],c=b.clientX-A.clientX,d=b.clientY-A.clientY,e="translate3d("+c+"px,"+d+"px,0)";B=b,i(s,"webkitTransform",e),i(s,"mozTransform",e),i(s,"msTransform",e),i(s,"transform",e),this._onDrag(b),a.preventDefault()}},_onDragStart:function(a,b){var c=a.dataTransfer,d=this.options;if(this._offUpEvents(),b){var e,g=q.getBoundingClientRect(),h=i(q);s=q.cloneNode(!0),i(s,"top",g.top-G(h.marginTop,10)),i(s,"left",g.left-G(h.marginLeft,10)),i(s,"width",g.width),i(s,"height",g.height),i(s,"opacity","0.8"),i(s,"position","fixed"),i(s,"zIndex","100000"),u.appendChild(s),e=s.getBoundingClientRect(),i(s,"width",2*g.width-e.width),i(s,"height",2*g.height-e.height),f(F,"touchmove",this._onTouchMove),f(F,"touchend",this._onDrop),f(F,"touchcancel",this._onDrop),this._loopId=setInterval(this._emulateDragOver,150)}else c.effectAllowed="move",d.setData&&d.setData.call(this,c,q),f(F,"drop",this);if(setTimeout(this._applyEffects,0),v=d.scroll,v===!0){v=u;do if(v.offsetWidth=i-g)-(e>=g),l=(e>=j-h)-(e>=h);k||l?b=E:v&&(b=v,c=v.getBoundingClientRect(),k=(M(c.right-g)<=e)-(M(c.left-g)<=e),l=(M(c.bottom-h)<=e)-(M(c.top-h)<=e)),(C.vx!==k||C.vy!==l||C.el!==b)&&(C.el=b,C.vx=k,C.vy=l,clearInterval(C.pid),b&&(C.pid=setInterval(function(){b===E?E.scrollTo(E.scrollX+k*f,E.scrollY+l*f):(l&&(b.scrollTop+=l*f),k&&(b.scrollLeft+=k*f))},24)))}},30),_onDragOver:function(a){var c,e,f,g=this.el,h=this.options,j=h.group,k=j.put,n=z===j,o=h.sort;if(void 0!==a.stopPropagation&&a.stopPropagation(),!I&&z&&(n?o||(f=!u.contains(q)):z.pull&&k&&(z.name===j.name||k.indexOf&&~k.indexOf(z.name)))&&(void 0===a.rootEl||a.rootEl===this.el)){if(c=d(a.target,h.draggable,g),e=q.getBoundingClientRect(),f)return b(!0),t||w?u.insertBefore(q,t||w):o||u.appendChild(q),void 0;if(0===g.children.length||g.children[0]===s||g===a.target&&(c=m(g,a))){if(c){if(c.animated)return;r=c.getBoundingClientRect()}b(n),g.appendChild(q),this._animate(e,q),c&&this._animate(r,c)}else if(c&&!c.animated&&c!==q&&void 0!==c.parentNode[D]){x!==c&&(x=c,y=i(c));var p,r=c.getBoundingClientRect(),v=r.right-r.left,A=r.bottom-r.top,B=/left|right|inline/.test(y.cssFloat+y.display),C=c.offsetWidth>q.offsetWidth,E=c.offsetHeight>q.offsetHeight,F=(B?(a.clientX-r.left)/v:(a.clientY-r.top)/A)>.5,G=c.nextElementSibling;I=!0,setTimeout(l,30),b(n),p=B?c.previousElementSibling===q&&!C||F&&C:G!==q&&!E||F&&E,p&&!G?g.appendChild(q):c.parentNode.insertBefore(q,p?G:c),this._animate(e,q),this._animate(r,c)}}},_animate:function(a,b){var c=this.options.animation;if(c){var d=b.getBoundingClientRect();i(b,"transition","none"),i(b,"transform","translate3d("+(a.left-d.left)+"px,"+(a.top-d.top)+"px,0)"),b.offsetWidth,i(b,"transition","all "+c+"ms"),i(b,"transform","translate3d(0,0,0)"),clearTimeout(b.animated),b.animated=setTimeout(function(){i(b,"transition",""),b.animated=!1},c)}},_offUpEvents:function(){g(F,"mouseup",this._onDrop),g(F,"touchmove",this._onTouchMove),g(F,"touchend",this._onDrop),g(F,"touchcancel",this._onDrop)},_onDrop:function(b){var c=this.el;if(clearInterval(this._loopId),clearInterval(C.pid),g(F,"drop",this),g(F,"dragover",this),g(c,"dragstart",this._onDragStart),this._offUpEvents(),b){if(b.preventDefault(),b.stopPropagation(),s&&s.parentNode.removeChild(s),q){g(q,"dragend",this);var d=o(q);k(q),h(q,this.options.ghostClass,!1),u.contains(q)?q.nextSibling!==w&&(J(u,"update",q,u,r,d),J(u,"sort",q,u,r,d),t&&t.parentNode.removeChild(t)):(J(q.parentNode,"sort",q,u,r,d),J(u,"sort",q,u,r,d),J(q,"add",q,u,r,d),J(u,"remove",q,u,r,d)),J(u,"end",q,u,r,d)}u=q=s=w=t=A=B=x=y=z=a.active=null,this.options.store&&this.options.store.set(this)}},handleEvent:function(a){var b=a.type;"dragover"===b?(this._onDrag(a),e(a)):("drop"===b||"dragend"===b)&&this._onDrop(a)},toArray:function(){for(var a,b=[],c=this.el.children,e=0,f=c.length;f>e;e++)a=c[e],d(a,this.options.draggable,this.el)&&b.push(a.getAttribute("data-id")||n(a));return b},sort:function(a){var b={},c=this.el;this.toArray().forEach(function(a,e){var f=c.children[e];d(f,this.options.draggable,c)&&(b[a]=f)},this),a.forEach(function(a){b[a]&&(c.removeChild(b[a]),c.appendChild(b[a]))})},closest:function(a,b){return d(a,b||this.options.draggable,this.el)},option:function(a,b){var c=this.options;return void 0===b?c[a]:(c[a]=b,void 0)},destroy:function(){var a=this.el,b=this.options;K.forEach(function(c){g(a,c.substr(2).toLowerCase(),b[c])}),g(a,"mousedown",this._onTapStart),g(a,"touchstart",this._onTapStart),g(a,"selectstart",this._onTapStart),g(a,"dragover",this._onDragOver),g(a,"dragenter",this._onDragOver),Array.prototype.forEach.call(a.querySelectorAll("[draggable]"),function(a){a.removeAttribute("draggable")}),O.splice(O.indexOf(this._onDragOver),1),this._onDrop(),this.el=null}},a.utils={on:f,off:g,css:i,find:j,bind:c,is:function(a,b){return!!d(a,b,a)},throttle:p,closest:d,toggleClass:h,dispatchEvent:J,index:o},a.version="0.7.3",a.create=function(b,c){return new a(b,c)},a}); \ No newline at end of file diff --git a/bower.json b/bower.json index a986404..f3aa12b 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "Sortable", "main": "Sortable.js", - "version": "0.7.2", + "version": "0.7.3", "homepage": "http://rubaxa.github.io/Sortable/", "authors": [ "RubaXa " diff --git a/component.json b/component.json index f9a9214..3287bdc 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "Sortable", "main": "Sortable.js", - "version": "0.7.2", + "version": "0.7.3", "homepage": "http://rubaxa.github.io/Sortable/", "repo": "RubaXa/Sortable", "authors": [ diff --git a/package.json b/package.json index 3f5bb55..913e40a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sortablejs", "exportName": "Sortable", - "version": "0.7.2", + "version": "0.7.3", "devDependencies": { "grunt": "*", "grunt-version": "*",