cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected scroll wheel behavior

brohr01
Associate III

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?

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

 

brohr01
Associate III

I want to revisit this issue with a better explanation and more details.

I have a circular scroll wheel with 10 elements, each element is displaying a single number 0-9.  If I set the scroll wheel in code by callingscrollwheel.animateToItem(9, 20); and then call  callingscrollwheel.animateToItem(0, 20); the wheel will animate from scrolling all digits from 9 down to zero.

But if I reverse the order of the calls, callingscrollwheel.animateToItem(0, 20); and then callingscrollwheel.animateToItem(9, 20); the scroll wheel acts as expected and will animate directly from 0 to 9.

This appears to be a bug to me as the circular scrollwheel is only behaving as a circular wheel in one direction where animating in this order 2, 1, 0, 9, 8...works as expected, and animating from 8, 9, 0, 1, 2 does not act like a circular wheel.

If I change the scrollwheel to not be circular if will always scroll through all digits when going from 0 to 9 and also when going 9 to 0.

You little miss idea. TGFX is TOUCH primary and circular here mean both direction work neverending...

Code control is other species.