mirror of https://github.com/espruino/BangleApps
kineticscroll - Add minified version for performance
parent
2f12b9ad6e
commit
7c874199c4
|
@ -0,0 +1,4 @@
|
|||
(function(){E.showScroller=function(c){function n(a){return a*c.h+b.y-k}function p(a){return Math.floor((a+k-b.y)/c.h)}if(!c)return Bangle.setUI();let h,e=0,l=0,t=setInterval(()=>{e*=.9},50),q=0,b=Bangle.appRect,m=0|c.scrollMin,r=c.h*c.c-b.h;r<m&&(r=m);let u=(a,d)=>{d.y<b.y-4||(l=e=0,a=p(d.y),(0>m||0<=a)&&a<c.c&&c.select(a,{x:d.x,y:d.y+k-b.y-a*c.h}))},v=()=>{var a=e;f.scroll-a>r&&(a=f.scroll-r,e=0);f.scroll-a<m&&(a=f.scroll-m,e=0);f.scroll-=a;a=k;k=f.scroll&-2;a-=k;h=.01<Math.abs(e)?setTimeout(v,
|
||||
0):void 0;if(a){g.reset().setClipRect(b.x,b.y,b.x2,b.y2).scroll(0,a);if(0>a){a=Math.max(b.y2-(1-a),b.y);g.setClipRect(b.x,a,b.x2,b.y2);var d=p(a);for(a=n(d);a<b.y2;a+=c.h)c.draw(d,{x:b.x,y:a,w:b.w,h:c.h}),d++}else for(a=Math.min(b.y+a,b.y2),g.setClipRect(b.x,b.y,b.x2,a),d=p(a),n(d),a=n(d);a>b.y-c.h;a-=c.h)c.draw(d,{x:b.x,y:a,w:b.w,h:c.h}),d--;g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)}},w={mode:"custom",back:c.back,remove:()=>{h&&clearTimeout(h);clearInterval(t);c.remove&&c.remove()},drag:a=>
|
||||
{if(0>e&&0<a.dy||0<e&&0>a.dy)e*=-1,l=5*e;0<a.b&&(q||(q=Date.now(),l=e=0),l+=a.dy);e=l/(Date.now()-q)*100;q&&0==a.b&&(q=l=0);e=E.clip(e,-100,100);lastDrag=Date.now();h||(h=setTimeout(v,0))},touch:u};c.remove&&(w.remove=()=>{h&&clearTimeout(h);clearInterval(t);c.remove&&c.remove()});Bangle.setUI(w);let f={scroll:E.clip(0|c.scroll,m,r),draw:()=>{g.reset().clearRect(b).setClipRect(b.x,b.y,b.x2,b.y2);var a=p(b.y);let d=Math.min(p(b.y2),c.c-1);for(;a<=d;a++)c.draw(a,{x:b.x,y:n(a),w:b.w,h:c.h});g.setClipRect(0,
|
||||
0,g.getWidth()-1,g.getHeight()-1)},drawItem:a=>{let d=n(a);g.reset().setClipRect(b.x,Math.max(d,b.y),b.x2,Math.min(d+c.h,b.y2));c.draw(a,{x:b.x,y:d,w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},isActive:()=>Bangle.touchHandler==u},k=f.scroll&-2;f.draw();g.flip();return f}})()
|
|
@ -9,6 +9,6 @@
|
|||
"supports" : ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"kineticscroll.boot.js","url":"boot.js"}
|
||||
{"name":"kineticscroll.boot.js","url":"boot.min.js"}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue