I am trying to create a social app like TikTok or Instagram. When the user tries to scroll up or down I want them to go up or down. I have some code I got from the docs but it doesn’t work. It prints in the console that the scroll view was touched but nothing else happens.
So how can I scroll up or down with my app when the user tries too ?
-- ScrollView listener
local function scrollListener( event )
local phase = event.phase
if ( phase == "began" ) then print( "Scroll view was touched" )
elseif ( phase == "moved" ) then print( "Scroll view was moved" )
elseif ( phase == "ended" ) then print( "Scroll view was released" )
end
-- In the event a scroll limit is reached...
if ( event.limitReached ) then
if ( event.direction == "up" ) then print( "Reached bottom limit" )
elseif ( event.direction == "down" ) then print( "Reached top limit" )
elseif ( event.direction == "left" ) then print( "Reached right limit" )
elseif ( event.direction == "right" ) then print( "Reached left limit" )
end
end
return true
end
-- Create the widget
local scrollView = widget.newScrollView(
{
top = 100,
left = 10,
width = 300,
height = 400,
scrollWidth = 600,
scrollHeight = 800,
listener = scrollListener
}
)