[ListItemDragHandle] Bugfix: Auto-scroll upwards not working due to rounding real values to integers
Description
Brief: Auto-scroll upwards works inconsistently due to a rounding down operation caused by mismatched variable types.
In onPositionChanged callback, the following assignments cause the bug because listItem.y is a real value and internal.listItemLastY is defined as integer.
@@210 internal.draggingUp = listItem.y < internal.listItemLastY
@@211 internal.listItemLastY = listItem.y;
@@216 scrollTimer.running = (listView.contentHeight > listView.height)
&& ((listItem.y === 0 && !listView.atYBeginning)
|| (listItem.y === mouseArea.drag.maximumY && !listView.atYEnd));
Case
- In order to detect
internal.draggingUp, currentlistItem.yand previous one is compared - Assume current
listItem.yis close to 0 but not 0 (0.02) - It will be stored as 0
- In the next callback to the same function, the new
listItem.ywill be zero if user keep dragging upwards - But instead of 0 < 0.02 comparison, the code will compare 0 < 0 and return false
- As a result, it will not auto-scroll top
Solution
- Make
listItemLastYa real type - Even though
mouseDownYandstartYare irrelevant in this bug, they should be real type too because the values they are assigned to are real values and may cause bugs for other behaviors