Dirty Larry - I want to use scrolling within the scroll (SOLVED)

I want to make a moving part that scrolls partially in the moving scroll. I am currently using Dirtylarry and I am struggling alone. But I do not get what I want.
Move the entire scroll vertically before telling what you want. Partial scrolling moves horizontally. To move the partial scroll instead of the full scroll, drag the horizontal scroll. Conversely, dragging vertically will attempt to move the entire scroll.

Everything on my PC went the way I wanted, but it’s odd that it works on the phone.
The odd thing is that the scroll position changes when you touch it.

Below is the script I created.

local Lb_scroll = {
					active = false,
					column = true,
					fav = true,
					genre = true
					}

function on_input(self, action_id, action)
	if Lb_scroll.column then
		self.scroll = larry:scrollarea("all_scroll", action_id, action, self.scroll, function(self, action_id, action) end)
		self.scroll.drag = true
	elseif Lb_scroll.fav then
		self.scroll_fav = larry:scrollarea("fav_scroll", action_id, action, self.scroll_fav, function(self, action_id, action) end)
		self.scroll_fav.drag = true
	elseif Lb_scroll.genre then
		self.scroll_genre = larry:scrollarea("genre_scroll", action_id, action, self.scroll_genre, function(self, action_id, action) end)
		self.scroll_genre.drag = true
	end
	
	if action_id == hash("touch") then
		if action.released then
			Lb_scroll.column = true
			Lb_scroll.fav = false
			Lb_scroll.genre = false
			Lb_scroll.active = false
		end
		
		if gui.pick_node(gui.get_node("fav_scroll"), action.x, action.y) and action.pressed then
			print("fav pressed")
			Lb_scroll.fav = true
			Lb_scroll.active = true
		elseif Lb_scroll.active and gui.pick_node(gui.get_node("fav_scroll"), action.x, action.y) and action.dx == 0 and action.dy ~= 0 then
			print("dy")
			Lb_scroll.fav = false
			Lb_scroll.active = false
		elseif Lb_scroll.active and gui.pick_node(gui.get_node("fav_scroll"), action.x, action.y) and action.dy == 0 and action.dx ~= 0 then
		print("dx")
			Lb_scroll.fav = true
			Lb_scroll.genre = false
			Lb_scroll.active = false
			Lb_scroll.column = false
		end
		
		if gui.pick_node(gui.get_node("genre_scroll"), action.x, action.y) and action.pressed then
			print("genre pressed")
			Lb_scroll.genre = true
			Lb_scroll.active = true
		elseif Lb_scroll.active and gui.pick_node(gui.get_node("genre_scroll"), action.x, action.y) and action.dx == 0 and (action.dy >= 2 or action.dy <= -2) then
			Lb_scroll.genre = false
			Lb_scroll.active = false
		elseif Lb_scroll.active and gui.pick_node(gui.get_node("genre_scroll"), action.x, action.y) and (action.dx >= 2 or action.dx <= -2) and action.dy == 0 then
			Lb_scroll.fav = false
			Lb_scroll.genre = true
			Lb_scroll.active = false
			Lb_scroll.column = false
		end
    end
end

I haven’t dug into the scroll functionality provided by Dirty Larry. Maybe @sven can spot the problem?

Hi!

I’m not 100% sure I understand what you want to achieve, would you mind adding me to the project so I can investigate?

The larry:scrollarea is quite new functionality that I haven’t had time to fully iron out yet myself. :slight_smile:

Okay.
Please let me know your email and I will invite you to the project.

Oh of course, sorry; sven.andersson@king.com

I invited you.
You need to refer to it. There is no problem with the PC. But there is a problem on the phone.

Thanks!

I think I have found the issue, it seems that we (Defold) incorrectly sets a delta x/y of non-zero when a touch starts on devices, on desktop this is always zero.

A workaround in your case would be to modify dirtylarry.lua by overwriting the action.dx and action.dy to 0 in the following if-statement;

    	-- potentially start scroll/drag
    	elseif hit and action.pressed then
    		scroll.started = true
    		action.dx = 0
    		action.dy = 0

That seems to fix it when I try locally here.

I’m not sure if I will do a fix for this in the dirtylarry myself, since I think it’s actually a bug in Defold. I’ll add an issue for it instead in our backlog; DEF-2712

7 Likes

Great! Thank you so much.

1 Like