1 |
- !function(a){var b=a.className("pull-top-tips");a.PullToRefresh=a.PullToRefresh.extend({init:function(b,c){this._super(b,c),this.options=a.extend(!0,{down:{tips:{colors:["008000","d8ad44","d00324","dc00b8","017efc"],size:200,lineWidth:15,duration:1e3,tail_duration:2500}}},this.options),this.options.down.tips.color=this.options.down.tips.colors[0],this.options.down.tips.colors=this.options.down.tips.colors.map(function(a){return{r:parseInt(a.substring(0,2),16),g:parseInt(a.substring(2,4),16),b:parseInt(a.substring(4,6),16)}})},initPullDownTips:function(){var c=this;a.isFunction(c.options.down.callback)&&(c.pullDownTips=function(){var a=document.querySelector("."+b);return a&&a.parentNode.removeChild(a),a||(a=document.createElement("div"),a.classList.add(b),a.innerHTML='<div class="mui-pull-top-wrapper"><div class="mui-pull-top-canvas"><canvas id="pullDownTips" width="'+c.options.down.tips.size+'" height="'+c.options.down.tips.size+'"></canvas></div></div>',a.addEventListener("webkitTransitionEnd",c),document.body.appendChild(a)),c.pullDownCanvas=document.getElementById("pullDownTips"),c.pullDownCanvasCtx=c.pullDownCanvas.getContext("2d"),c.canvasUtils.init(c.pullDownCanvas,c.options.down.tips),a}())},removePullDownTips:function(){this._super(),this.canvasUtils.stopSpin()},pulling:function(a){var b=Math.min(a/(1.5*this.options.down.height),1),c=Math.min(1,2*b);this.pullDownTips.style.webkitTransform="translate3d(0,"+(0>a?0:a)+"px,0)",this.pullDownCanvas.style.opacity=c,this.pullDownCanvas.style.webkitTransform="rotate("+300*b+"deg)";var d=this.pullDownCanvas,e=this.pullDownCanvasCtx,f=this.options.down.tips.size;e.lineWidth=this.options.down.tips.lineWidth,e.fillStyle="#"+this.options.down.tips.color,e.strokeStyle="#"+this.options.down.tips.color,e.stroke(),e.clearRect(0,0,f,f),d.style.display="none",d.offsetHeight,d.style.display="inherit",this.canvasUtils.drawArcedArrow(e,f/2+.5,f/2,f/4,0*Math.PI,5/3*Math.PI*c,!1,1,2,.7853981633974483,25,this.options.down.tips.lineWidth,this.options.down.tips.lineWidth)},beforeChangeOffset:function(a){},afterChangeOffset:function(a){},dragEndAfterChangeOffset:function(a){a?(this.canvasUtils.startSpin(),this.pullDownLoading()):(this.canvasUtils.stopSpin(),this.endPullDownToRefresh())},canvasUtils:function(){function b(a,b,c,d){return c*a/d+b}function c(a,b,c,d){return(a/=d/2)<1?c/2*a*a+b:-c/2*(--a*(a-2)-1)+b}function d(a,b,c){var d=Math.min(b,c),e=Math.max(b,c);return d>a?d:a>e?d:a}var e=null,f=null,g=200,h=15,i=0,j=0,k=0,l=0,m=0,n=180,o=Math.PI/180,p=1e3,q=2500,r=["35ad0e","d8ad44","d00324","dc00b8","017efc"],s=null,t=function(a,b,c,d,e,f,g,h){"use strict";"string"==typeof b&&(b=parseInt(b)),"string"==typeof c&&(c=parseInt(c)),"string"==typeof d&&(d=parseInt(d)),"string"==typeof e&&(e=parseInt(e)),"string"==typeof f&&(f=parseInt(f)),"string"==typeof g&&(g=parseInt(g));2*Math.PI;switch(a.save(),a.beginPath(),a.moveTo(b,c),a.lineTo(d,e),a.lineTo(f,g),h){case 0:var i=Math.sqrt((f-b)*(f-b)+(g-c)*(g-c));a.arcTo(d,e,b,c,.55*i),a.fill();break;case 1:a.beginPath(),a.moveTo(b,c),a.lineTo(d,e),a.lineTo(f,g),a.lineTo(b,c),a.fill();break;case 2:a.stroke();break;case 3:var j=(b+d+f)/3,k=(c+e+g)/3;a.quadraticCurveTo(j,k,b,c),a.fill();break;case 4:var l,m,n,o,i,p=5;if(f==b)i=g-c,l=(d+b)/2,n=(d+b)/2,m=e+i/p,o=e-i/p;else{i=Math.sqrt((f-b)*(f-b)+(g-c)*(g-c));var q=(b+f)/2,r=(c+g)/2,s=(q+d)/2,t=(r+e)/2,u=(g-c)/(f-b),v=i/(2*Math.sqrt(u*u+1))/p,w=u*v;l=s-v,m=t-w,n=s+v,o=t+w}a.bezierCurveTo(l,m,n,o,b,c),a.fill()}a.restore()},u=function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";h="undefined"!=typeof h?h:3,i="undefined"!=typeof i?i:1,j="undefined"!=typeof j?j:Math.PI/8,l=l||1,m=m||10,k="undefined"!=typeof k?k:10,a.save(),a.lineWidth=l,a.beginPath(),a.arc(b,c,d,e,f,g),a.stroke();var n,o,p,q,r;1&i&&(n=Math.cos(e)*d+b,o=Math.sin(e)*d+c,p=Math.atan2(b-n,o-c),g?(q=n+10*Math.cos(p),r=o+10*Math.sin(p)):(q=n-10*Math.cos(p),r=o-10*Math.sin(p)),v(a,n,o,q,r,h,2,j,k)),2&i&&(n=Math.cos(f)*d+b,o=Math.sin(f)*d+c,p=Math.atan2(b-n,o-c),g?(q=n-10*Math.cos(p),r=o-10*Math.sin(p)):(q=n+10*Math.cos(p),r=o+10*Math.sin(p)),v(a,n-m*Math.sin(f),o+m*Math.cos(f),q-m*Math.sin(f),r+m*Math.cos(f),h,2,j,k)),a.restore()},v=function(a,b,c,d,e,f,g,h,i){"use strict";"string"==typeof b&&(b=parseInt(b)),"string"==typeof c&&(c=parseInt(c)),"string"==typeof d&&(d=parseInt(d)),"string"==typeof e&&(e=parseInt(e)),f="undefined"!=typeof f?f:3,g="undefined"!=typeof g?g:1,h="undefined"!=typeof h?h:Math.PI/8,i="undefined"!=typeof i?i:10;var j,k,l,m,n="function"!=typeof f?t:f,o=Math.sqrt((d-b)*(d-b)+(e-c)*(e-c)),p=(o-i/3)/o;1&g?(j=Math.round(b+(d-b)*p),k=Math.round(c+(e-c)*p)):(j=d,k=e),2&g?(l=b+(d-b)*(1-p),m=c+(e-c)*(1-p)):(l=b,m=c),a.beginPath(),a.moveTo(l,m),a.lineTo(j,k),a.stroke();var q=Math.atan2(e-c,d-b),r=Math.abs(i/Math.cos(h));if(1&g){var s=q+Math.PI+h,u=d+Math.cos(s)*r,v=e+Math.sin(s)*r,w=q+Math.PI-h,x=d+Math.cos(w)*r,y=e+Math.sin(w)*r;n(a,u,v,d,e,x,y,f)}if(2&g){var s=q+h,u=b+Math.cos(s)*r,v=c+Math.sin(s)*r,w=q-h,x=b+Math.cos(w)*r,y=c+Math.sin(w)*r;n(a,u,v,b,c,x,y,f)}},w=function(a,c){var e=a%c;k>e&&r.push(r.shift());var f=r[0],g=r[1],h=d(b(e,f.r,g.r-f.r,c),f.r,g.r),i=d(b(e,f.g,g.g-f.g,c),f.g,g.g),j=d(b(e,f.b,g.b-f.b,c),f.b,g.b);return k=e,"rgb("+parseInt(h)+","+parseInt(i)+","+parseInt(j)+")"},x=function(a){var d=a||(new Date).getTime();j||(j=d),i=d-j,l=c((i+q/2)%q,0,p,q),m=b((i+l)%p,0,360,p),n=20+Math.abs(b((i+q/2)%q,-300,600,q)),f.lineWidth=h,f.lineCap="round",f.strokeStyle=w(i,p),f.clearRect(0,0,g,g),e.style.display="none",e.offsetHeight,e.style.display="inherit",f.beginPath(),f.arc(g/2,g/2,g/4,parseInt(m-n)%360*o,parseInt(m)%360*o,!1),f.stroke(),s=requestAnimationFrame(x)},y=function(){j=0,k=0,s=requestAnimationFrame(x)},z=function(){s&&cancelAnimationFrame(s)},A=function(b,c){e=b,f=e.getContext("2d");var c=a.extend(!0,{},c);r=c.colors,p=c.duration,q=c.tail_duration,g=c.size,h=c.lineWidth};return{init:A,drawArcedArrow:u,startSpin:y,stopSpin:z}}()})}(mui);
|