Smooth group scrolling
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Smooth group scrolling
Hi,
I have an app that includes a scrolling group. When the user scrolls he has to keep his finger on the screen and he can't release until he finish his scrolling.
I want to give the user the option to scroll a bit but fast and let the group keep scrolling after he released his finger.
Is it possible in livecode? If it is, how do I do that?
Thanks
I have an app that includes a scrolling group. When the user scrolls he has to keep his finger on the screen and he can't release until he finish his scrolling.
I want to give the user the option to scroll a bit but fast and let the group keep scrolling after he released his finger.
Is it possible in livecode? If it is, how do I do that?
Thanks
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Smooth group scrolling
Everything is possible in LC.
You have given me an excuse to stop working and check this out. Thank you
Craig
You have given me an excuse to stop working and check this out. Thank you
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Smooth group scrolling
Well, I have to get back to work. But try this. On a new card make a long scrolling group. Shorten the group so a scrollBar appears. Perhaps the group might have controls that you can see scroll by as you drag. Now make a button as tall as the group. Overlay the button on top of the group scrollbar for now.
There is a problem with this whole idea, and it centers on the fact that a scrollbar does not send messages very well. So I made a kludge, in that you have to do your scrolling in the tall field, not the group. But we can make that look right later on. In the button script:
Enter the button, click and drag. Release the button. The scroll will continue until the end is reached, or you click the mouse.
Now this needs a little work. The speed of the scroll in the group should be done better, based on the differences in the variable "moveLog". It is likely that other things need tweaking as well.
Craig
There is a problem with this whole idea, and it centers on the fact that a scrollbar does not send messages very well. So I made a kludge, in that you have to do your scrolling in the tall field, not the group. But we can make that look right later on. In the button script:
Code: Select all
global moveLog
on mouseDown
put "" into moveLog
end mouseDown
on mouseUp
keepScrolling yTravel,timeTravel
end mouseUp
on mouseMove x,y
if the mouseLoc is within the rect of me then put y & "," & the ticks & return after moveLog
if the mouse is down then
if item 1 of line -2 of moveLog > item 1 of line -1 of moveLog then set the scroll of grp 1 to the scroll of grp 1 - 1
else set the scroll of grp 1 to the scroll of grp 1 + 1
end if
end mouseMove
on keepScrolling ytravel,timeTravel
put the ticks into startTime
put item 1 of line -5 of moveLog - item 1 of line -1 of moveLog into yTravel
put item 2 of line -5 of moveLog - item 2 of line -1 of moveLog into timeTravel
repeat until the mouseClick
if the ticks mod abs(timeTravel) > 0 then
switch
case yTravel < 0
set the scroll of grp 1 to the scroll of grp 1 + 1
break
case yTravel > 0
set the scroll of grp 1 to the scroll of grp 1 - 1
break
end switch
end if
end repeat
end keepScrolling
Now this needs a little work. The speed of the scroll in the group should be done better, based on the differences in the variable "moveLog". It is likely that other things need tweaking as well.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Smooth group scrolling
Jason, have you scripted a mobile overlay control over the object you want to scroll more smoothly?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Smooth group scrolling
Is that what was meant? I read it as the scroll process keeps going after it has been "run" for a short time and the user lets go of the mouse or screen.
Craig
Craig
Last edited by dunbarx on Sat Jan 23, 2021 12:54 am, edited 1 time in total.
Re: Smooth group scrolling
Craig,
It works well on my computer I only found that rarely when i swipe up it swipes the group down but that's not a big problem.
But when I tried this on my android phone it didn't continue to scroll after i released my finger. I am currently trying to solve this, I will update you when it will work.
Anyways, thank you so much. I appreciate that.
I use the verical scrollbar property of the group. what do you mean by "mobile overlay control"?
thanks
It works well on my computer I only found that rarely when i swipe up it swipes the group down but that's not a big problem.
But when I tried this on my android phone it didn't continue to scroll after i released my finger. I am currently trying to solve this, I will update you when it will work.
Anyways, thank you so much. I appreciate that.
Hi FourthWorld,FourthWorld wrote: ↑Fri Jan 22, 2021 7:54 pmJason, have you scripted a mobile overlay control over the object you want to scroll more smoothly?
I use the verical scrollbar property of the group. what do you mean by "mobile overlay control"?
thanks
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Smooth group scrolling
A future version of the engine will automatically instantiate the interactive overlay needed for smooth mobile-native scrolling of scrollable objects like fields and groups.
For now, you'll need to script that scroller yourself - takes just a few lines, described here:
https://lessons.livecode.com/m/4069/l/1 ... ll-a-group
For now, you'll need to script that scroller yourself - takes just a few lines, described here:
https://lessons.livecode.com/m/4069/l/1 ... ll-a-group
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Smooth group scrolling
Hi FourthWorld,
It works perfectly,
I heard about the custom scrollbar before and I followed the tutorial "custom-controls" (it doesn't let me send a link), but it didn't help me.
The tutorial you sent me was great and now it's working well.
Craig, FourthWorld,
thank you so much. You’re the best!
It works perfectly,
I heard about the custom scrollbar before and I followed the tutorial "custom-controls" (it doesn't let me send a link), but it didn't help me.
The tutorial you sent me was great and now it's working well.
Craig, FourthWorld,
thank you so much. You’re the best!
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Smooth group scrolling
Happy to help, Jason. Keep us posted if you run into anything else you could use a hand with.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn