2024-11-09 06:21 PM
I have created a project with a scroll wheel of 10 items, each item is displaying a single digit 0-9. Imagine an odometer for instance. I am incrementing a variable(num) every second and using
scrollWheel.animateToItem(num, 20);
to scroll through the list of items, it is working as expected until it gets to 9. Instead of it the scroll wheel continuing to rotate the same direction to 0 it reverses the direction of rotation and scroll past all other digits to get back to zero.
I have verified I have the scroll wheel set as "Circular" and it does indeed display the scroll wheel correctly as if it was circular. Can I somehow change this behavior?
2024-11-10 12:01 AM
Try combine with
virtual void | animateToPosition(int32_t position, int16_t steps =-1) |
2024-11-10 04:42 AM
You can use the modulus operator to calculate which item to display while keeping a continuous count for num so that the scroll wheel always has a “forward” motion.
let num = 0;
setInterval(() => {
scrollWheel.animateToItem(num % 10, 20);
num++; // Keep incrementing num indefinitely
}, 1000);