cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected scroll wheel behavior

brohr01
Associate II

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?

2 REPLIES 2
MM..1
Chief III

Try combine with 

virtual voidanimateToPosition(int32_t position, int16_t steps =-1)
liaifat85
Senior III

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);