Issue with scrollView component

Hi,

i created a simple scrollView with only one imageRect in it. When i start to dragging up or down everthing works as i expect, the content moves directly when i start my drag.
But when i drag to left or right, the conent dont moves directly, i must drag some distance and then the content starts to move.
Why does it behave differently in both axes? How can i fix it? Its not a problem in simulator, on my real mobil phone the behavior is same.

Thanks.

Here is a gif that shows the behavior:
scrollViewTest

Code:

– Create the widget

local scrollView = widget.newScrollView(

    {

        x = display.contentCenterX,

        y = display.contentCenterY,

        width = 35,

        height = 35,

        scrollWidth = 50,

        scrollHeight = 50

    }

)

local test = display.newImageRect(uiGroup, "images/level_choose/3.png", 50, 50)

test.x = scrollView.width/2 + 7.5

test.y = scrollView.height/2 + 7.5

scrollView:insert( test )

Found the problem.
I looked in the widget lib code. In the movement logic there is a threshold/offset of 12. If the drag distance (event.x - event.xStart) is smaller than 12, the scrollview doesnt recognize that it is a horizontal movement.
In my project settings i configured a small width (50). So with this small width the behavior is strange. But if you have a bigger width (for example 800) you dont notice the issue much, because a threshold/offset of 12 to recognize a horizontal movement is not much relative to 800 width.
The issue is that you cant confiure the value (12) of the treshold from outside, for example at creation of the scrollView. So atm the only way to change the code is to download it from github and change it locally and import/require it in your project. If the width is set large enough, you will not notice the behavior at all.

For the vertical scrolling this issue dont occours, because the movement code assumes that the user scrolls vertically as default. So the vertical movement code gets called even if the drag distance of 12 (vertical) is not reached.

I hope this reply helps others if they have the same issue.
Maybe this code can be modify generally, to improve this behavior or make threshold/offset configurable.

1 Like