From 9fd1a68e725e9cfefd197bd0a32697d03a87a56f Mon Sep 17 00:00:00 2001 From: barrior Date: Sun, 18 Jun 2017 11:27:12 +0800 Subject: [PATCH] adjust comments --- ddsort.js | 11 +---------- ddsort.min.js | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/ddsort.js b/ddsort.js index 93152b8..6fb5cd3 100644 --- a/ddsort.js +++ b/ddsort.js @@ -1,15 +1,6 @@ /** - * Author: https://github.com/Barrior - * * DDSort: drag and drop sorting. - * @param {Object} options - * target[string]: 可选,jQuery 事件委托选择器字符串,默认 li - * delay[number]: 可选,延时拖拽,单位毫秒 - * cloneStyle[object]: 可选,设置占位符元素的样式 - * floatStyle[object]: 可选,设置拖动元素的样式 - * down[function]: 可选,鼠标按下时执行的函数 - * move[function]: 可选,鼠标移动时执行的函数 - * up[function]: 可选,鼠标抬起时执行的函数 + * Documentation: https://github.com/Barrior/DDSort */ +function ($) { var defaultOptions = { diff --git a/ddsort.min.js b/ddsort.min.js index 8618cf5..608866d 100644 --- a/ddsort.min.js +++ b/ddsort.min.js @@ -1,5 +1,5 @@ /** - * Author: https://github.com/Barrior * DDSort: drag and drop sorting. + * Documentation: https://github.com/Barrior/DDSort */ +function(b){var a={down:b.noop,move:b.noop,up:b.noop,target:"li",delay:100,cloneStyle:{"background-color":"#eee"},floatStyle:{position:"fixed","box-shadow":"10px 10px 20px 0 #eee",webkitTransform:"rotate(4deg)",mozTransform:"rotate(4deg)",msTransform:"rotate(4deg)",transform:"rotate(4deg)"}};b.fn.DDSort=function(c){var e=b(document);var d=b.extend(true,{},a,c);return this.each(function(){var g=b(this);var h="height";var f="width";if(g.css("box-sizing")=="border-box"){h="outerHeight";f="outerWidth"}g.on("mousedown.DDSort touchstart.DDSort",d.target,function(v){var z=new Date().getTime();if(v.type=="mousedown"&&v.which!=1){return}var s=v.target.tagName.toLowerCase();if(s=="input"||s=="textarea"||s=="select"||s=="a"||b(v.target).prop("contenteditable")=="true"){return}var t=this;var o=b(t);var n=o.offset();var j=v.pageX;var i=v.pageY;var w=v.originalEvent.targetTouches;if(v.type=="touchstart"&&w){j=w[0].pageX;i=w[0].pageY}var m=j-n.left;var l=i-n.top;var x=o.clone().css(d.cloneStyle).css("height",o[h]()).empty();var r=1;var k=o.outerHeight();var u=g.outerHeight();var p=k;var q=k;var y=k*3;d.down.call(t);e.on("mousemove.DDSort touchmove.DDSort",function(F){var D=F.pageX;var C=F.pageY;var H=F.originalEvent.targetTouches;if(F.type=="touchmove"&&H){D=H[0].pageX;C=H[0].pageY}if(new Date().getTime()-zE.offset().top+E.outerHeight()/2){x.before(E)}}var K=g.scrollTop();var J=g.offset().top;var G;if(Iy?y:p;G=K-p}else{if(I+k-J>u){p=k;q=++q>y?y:q;G=K+q}}g.scrollTop(G);d.move.call(t,A-e.scrollLeft(),I-e.scrollTop())}).on("mouseup.DDSort touchend.DDSort",function(){e.off("mousemove.DDSort mouseup.DDSort touchmove.DDSort touchend.DDSort");if(!r){x.before(o.removeAttr("style")).remove();d.up.call(t)}});return false})})}}(jQuery); \ No newline at end of file