-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathmaterial-refresh.min.js
1 lines (1 loc) · 3.65 KB
/
material-refresh.min.js
1
(function(){"use strict";!function(e){function n(n){if(n=n||{},g=n.scrollEl?n.scrollEl:Q?g:document,y=e(g),U=n.onBegin,H=n.onEnd,M=n.maxTime||M,O=n.nav||O,0===e("#muirefresh").length&&o(),m=e("#muiRefresh"),p=e(".mui-spinner-wrapper",m),h=e(".mui-arrow-wrapper",m),v=e(".mui-arrow-main",m),!d()){m.addClass("mui-refresh-nav"),S=e(O).height()+20,e(O).offset()&&(A=e(O).offset().top,"fixed"!==e(O).css("position")&&(S+=A),m.css("top",A+"px"));var t=e(O).css("z-index");m.css("z-index",t-1)}n.index&&m.css("z-index",~~n.index),n.top&&m.css("top",n.top),m.addClass(n.theme?n.theme:T),m.addClass(b),n.freeze||f()}function o(){document.body.insertAdjacentHTML("beforeend",Z)}function t(e){F.top=Q&&g==document.body?window.scrollY:g!=document?document.querySelector(g).scrollTop:(document.documentElement||document.body.parentNode||document.body).scrollTop,F.top>0||E||(w=S+z,m.show(),e=e.originalEvent||e,e.touches[0]&&(F.x1=e.touches[0].pageX,j=F.y1=e.touches[0].pageY))}function i(e){var n,o,t=(new Date).getTime();if(e=e.originalEvent||e,!(F.top>0||E)&&e.touches&&1===e.touches.length){if(n=e.touches[0],F.x2=n.pageX,F.y2=n.pageY,o=F.y2-F.y1,F.y2-j+B>0){if(e.preventDefault(),90>t-P)return;if(!(S-A+Y>w))return void u();w+=o,r(w)}F.y1=n.pageY,P=t}}function s(e){F.top>0||E||(e.preventDefault(),w>S-A+R?u():c())}function c(){var e=S+z;d()?(m.css("top",e+"px"),m.css("-webkit-transform","scale(0)")):m.css("top",A+"px"),setTimeout(function(){E||(m.css("opacity",0),m.hide())},300)}function r(e){var n=40,o=e/n>1?1:0>e/n?0:e/n,t=S+z+e;d()&&m.css("-webkit-transform","scale("+o+")"),m.css("opacity",o),m.css("top",t+"px"),v.css("-webkit-transform","rotate("+-(3*e)+"deg)")}function u(){if(E=!0,k&&"function"==typeof q?q():"function"==typeof U&&U(),m.css("opacity",1),k)m.addClass(b),m.css("-webkit-transform","scale(1)");else{var e=S+D-20;d()||(e+=X),m.css("top",e+"px")}h.hide(),p.show(),N=setTimeout(a,M)}function a(){C=!0,m.addClass(x),p.hide(),setTimeout(function(){m.removeClass(x),m.hide(),c(),h.show(),E=!1,C=!1,k&&"function"==typeof L?L():"function"==typeof H&&H(),k=!1},500)}function d(){return 0===e(O).length}function f(){y.on("touchstart",t),y.on("touchmove",i),y.on("touchend",s)}function l(){y.off("touchstart",t),y.off("touchmove",i),y.off("touchend",s)}var m,p,h,v,w,y=e(document.body),g=document.body,x="mui-refresh-noshow",b="mui-refresh-main-animat",T="mui-blue-theme",E=!1,C=!1,k=!1,z=-85,D=0,Y=65,R=-25,X=20,j=0,A=0,B=2,M=6e3,S=60,U=null,q=null,H=null,L=null,N=null,O="",P=(new Date).getTime(),Q=!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),Z='<div id="muiRefresh" class="mui-refresh-main"> <div class="mui-refresh-wrapper "> <div class="mui-arrow-wrapper"> <div class="mui-arrow-main"></div> </div> <div class="mui-spinner-wrapper" style="display:none;"> <div class="mui-spinner-main" > <div class="mui-spinner-left"> <div class="mui-half-circle"></div> </div> <div class="mui-spinner-right"> <div class="mui-half-circle"></div> </div> </div> </div> </div> </div>',F={top:0,x1:0,x2:0,y1:0,y2:0};n.resolve=function(){!C&&N&&(clearTimeout(N),N=null,a())},n.destroy=function(){l(),m.remove()},n.refresh=function(e){if(!E){var n=S+D-20;E=!0,k=!0,e=e||{},q=e.onBegin,L=e.onEnd,d()||(n+=X),m.show(),m.removeClass(b),m.css("top",n+"px"),m.css("-webkit-transform","scale(0.01)"),setTimeout(u,60)}},n.unbindEvents=function(){l()},n.bindEvents=function(){f()},window.mRefresh=n}(window.Zepto||window.jQuery)}).call(this);