kineticscroll - Directly draw while finger is touching
parent
ecf31ce94a
commit
6e67f6a806
|
|
@ -61,11 +61,14 @@
|
||||||
|
|
||||||
const draw = () => {
|
const draw = () => {
|
||||||
if (velocity > MIN_VELOCITY){
|
if (velocity > MIN_VELOCITY){
|
||||||
|
if (!scheduledDraw)
|
||||||
|
scheduledDraw = setTimeout(draw, 0);
|
||||||
velocity *= 1-((Date.now() - lastTouchedDrag) / 8000);
|
velocity *= 1-((Date.now() - lastTouchedDrag) / 8000);
|
||||||
if (velocity <= MIN_VELOCITY){
|
if (velocity <= MIN_VELOCITY){
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
|
} else {
|
||||||
|
s.scroll -= velocity * direction;
|
||||||
}
|
}
|
||||||
s.scroll -= velocity * direction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.scroll > menuScrollMax){
|
if (s.scroll > menuScrollMax){
|
||||||
|
|
@ -81,11 +84,6 @@
|
||||||
rScroll = s.scroll &~1;
|
rScroll = s.scroll &~1;
|
||||||
let d = oldScroll-rScroll;
|
let d = oldScroll-rScroll;
|
||||||
|
|
||||||
if (velocity > MIN_VELOCITY)
|
|
||||||
scheduledDraw = setTimeout(draw, 0);
|
|
||||||
else
|
|
||||||
scheduledDraw = undefined;
|
|
||||||
|
|
||||||
if (!d) {
|
if (!d) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -111,11 +109,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1);
|
g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1);
|
||||||
|
scheduledDraw = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const dragHandler = e=>{
|
const dragHandler = e=>{
|
||||||
let now=Date.now();
|
let now=Date.now();
|
||||||
direction = e.dy > 0 ? 1 : -1;
|
direction = Math.sign(e.dy);
|
||||||
s.scroll -= e.dy;
|
s.scroll -= e.dy;
|
||||||
if (e.b > 0){
|
if (e.b > 0){
|
||||||
// Finger touches the display or direction has been reversed
|
// Finger touches the display or direction has been reversed
|
||||||
|
|
@ -134,10 +133,7 @@
|
||||||
}
|
}
|
||||||
lastDragStart = 0;
|
lastDragStart = 0;
|
||||||
}
|
}
|
||||||
|
draw();
|
||||||
if (!scheduledDraw){
|
|
||||||
scheduledDraw = setTimeout(draw, 0);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let uiOpts = {
|
let uiOpts = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue