kineticscroll - Fix warnings and whitespace

master
Martin Boonk 2024-03-25 16:16:12 +01:00
parent ecbac6e017
commit 98325fa102
1 changed files with 21 additions and 20 deletions

View File

@ -51,7 +51,7 @@
for (var i=a;i<=b;i++) for (var i=a;i<=b;i++)
options.draw(i, {x:R.x,y:idxToY(i),w:R.w,h:options.h}); options.draw(i, {x:R.x,y:idxToY(i),w:R.w,h:options.h});
g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1); g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1);
} };
const draw = () => { const draw = () => {
let dy = velocity; let dy = velocity;
@ -136,14 +136,14 @@
drag : dragHandler, drag : dragHandler,
touch : touchHandler, touch : touchHandler,
redraw : uiDraw redraw : uiDraw
} };
if (options.remove) uiOpts.remove = () => { if (options.remove) uiOpts.remove = () => {
if (scheduledDraw) if (scheduledDraw)
clearTimeout(scheduledDraw); clearTimeout(scheduledDraw);
clearInterval(scheduledBrake); clearInterval(scheduledBrake);
options.remove(); options.remove();
} };
Bangle.setUI(uiOpts); Bangle.setUI(uiOpts);
@ -152,6 +152,7 @@
function idxToY(i) { function idxToY(i) {
return i*options.h + R.y - rScroll; return i*options.h + R.y - rScroll;
} }
function YtoIdx(y) { function YtoIdx(y) {
return Math.floor((y + rScroll - R.y)/options.h); return Math.floor((y + rScroll - R.y)/options.h);
} }