From 770449911ff6d3e372e1cec230e41dd6bce9a197 Mon Sep 17 00:00:00 2001 From: jadus Date: Tue, 1 Dec 2015 12:20:56 +0100 Subject: [PATCH] V1.1.0 --- jquery.sortScroll.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 jquery.sortScroll.min.js diff --git a/jquery.sortScroll.min.js b/jquery.sortScroll.min.js new file mode 100644 index 0000000..02d4dc3 --- /dev/null +++ b/jquery.sortScroll.min.js @@ -0,0 +1 @@ +!function(t,s,n,o){"use strict";function e(s,n){this.container=t(s),this.settings=t.extend({},i,n,this.container.data()),this._sorting=!1,this.elementClass="sort-scroll-element",this.sortingClass="sort-scroll-sorting",this.buttonUpClass="sort-scroll-button-up",this.buttonDownClass="sort-scroll-button-down",this.init()}var i={animationDuration:1e3,easing:"swing",keepStill:!0};t.extend(e.prototype,{init:function(){var s=this;s.container.on("click","."+s.buttonUpClass+", ."+s.buttonDownClass,function(n){var o,e=t(this),i=s.container.find("."+s.elementClass),r=i.index(e.closest("."+s.elementClass));o=e.hasClass(s.buttonUpClass)?-1:1,n.preventDefault(),s.sortElement(r,o,s.settings.keepStill)})},sortElement:function(o,e,i){e=-1===e?e:1,i=i?this.settings.keepStill:!1;var r=this,a=r.container.find("."+r.elementClass),l=a.length-1,c=o+e;if(0>c||c>l)return!1;var p=a.eq(o);if(r._sorting)return r.container.one("sortScroll.sortEnd",function(t,s,n,o){r.sortElement(o,e)}),!1;r.container.trigger("sortScroll.sortStart",[p,o,c]),r._sorting=!0;var u=p.outerHeight(!0),g=p.offset().top,h=a.eq(c),m=h.outerHeight(!0),d=h.offset().top,f=h.offset().top,C=d+u,v=Math.max(0,n.documentElement.scrollHeight-n.documentElement.clientHeight),x=t(s).scrollTop(),S=0,b=parseInt(h.css("margin-top"),10);e>0&&(f=g+m,C=g,S=parseInt(p.css("margin-top"),10),b=0);var y=f-g-S,w=C-d-b,E=x+y;E=Math.min(E,v),E=Math.max(E,0);var D,k=r.settings.animationDuration,H=r.settings.easing,_=p.css("position"),z=p.css("z-index");D="auto"===z?2:z+1,p.addClass(r.sortingClass),p.css({position:"relative","z-index":D}),p.animate({top:y+"px"},k,H),h.animate({top:w+"px"},k,H),i&&t("body").animate({scrollTop:E+"px"},k,H),a.add(t("html, body")).promise().done(function(){p.removeClass(r.sortingClass),p.css({position:_,"z-index":z}),e>0?h.after(p):h.before(p),p.css("top",0),h.css("top",0),r._sorting=!1,r.container.trigger("sortScroll.sortEnd",[p,o,c])})}}),t.fn.sortScroll=function(s){var n=Array.prototype.slice.call(arguments,1);return this.each(function(){var o=t(this),i=o.data("sortScroll");i?"string"==typeof s&&i[s].apply(i,n):o.data("sortScroll",new e(this,s))})}}(jQuery,window,document),$(".sort-scroll-container").each(function(){$(this).sortScroll()});