How to let scrollView snap back after using scrollToPosition

Hi, 

I am trying to emulate the scrollView scroll and snap back look in a scrollview after its loaded. I can use scrollToPosition to make the scrollView look as though it has been pulled to one side by the user but then I don’t know how to ‘release’ it so it snaps back. Is this at all possible given current API functionality?

Thanks much for your ideas. Regards,

Kerem

Appreciate any thoughts. I tried to put the scrollToPosition in a for loop to try and emulate the scrollView snapping back but it seems to have a mind of its own. No breakthrough yet. If there is a way to let a scrollView go back to its natural position after being pulled to one side using scrollToPosition I would much appreciate to hear about it. Thanks much!!!

If you are programmatically for ing a scrollView beyond its limits (I didn’t know you could) you might want to try a transition to animate it back into place. A timer is definitely not the way, but also setScrollPosition might do it if you use a time value.

Hi. Thanks for your input. I don’t think I’m forcing it beyond its limit. Just push a scrollview sideways and it goes about 1/2 of the screen width before you get event.limitReached in your listener. I’m using setScrollPosition to go just that much and then the scrollView just sits there. So I was wondering if there is a way to let it free, snap if you will back to neutral. 

Short of a method to do that I tried to programmatically bring it back home in a simulated snap back animation but so far no luck. Will try some more.

Have you tried this? http://docs.coronalabs.com/daily/api/type/ScrollViewWidget/scrollTo.html

Thanks for that. Will give that one a go. I am able to simulate the snap effect using the following 

 for p = 60, 0, -1 do scrollView:scrollToPosition({x= p, time=500}) end

How ever when this is tacked onto the end of another ‘finger’ induced snap it gets ignored. I will try the scrollTo and see if I can get anywhere with it. 

In case you’re wondering what I’m trying to do… I am setting my business app to go from one record to another with horizontal scrolls or swipes on the details page. I have it all working but the visual effect is not pleasing. Once you pull the scrollview to the right and let go it snaps back and gets replaced with the new record. I want to let the new record snap in from the other direction so that it looks like a new record coming in from the direction you pulled the original record. Apologies if this is not very clear. 

Maybe put a short timer delay in?

Definitely. I put the long one in to make the effect really obvious. It needs to be shorter to be more like the widget snap.

Appreciate any thoughts. I tried to put the scrollToPosition in a for loop to try and emulate the scrollView snapping back but it seems to have a mind of its own. No breakthrough yet. If there is a way to let a scrollView go back to its natural position after being pulled to one side using scrollToPosition I would much appreciate to hear about it. Thanks much!!!

If you are programmatically for ing a scrollView beyond its limits (I didn’t know you could) you might want to try a transition to animate it back into place. A timer is definitely not the way, but also setScrollPosition might do it if you use a time value.

Hi. Thanks for your input. I don’t think I’m forcing it beyond its limit. Just push a scrollview sideways and it goes about 1/2 of the screen width before you get event.limitReached in your listener. I’m using setScrollPosition to go just that much and then the scrollView just sits there. So I was wondering if there is a way to let it free, snap if you will back to neutral. 

Short of a method to do that I tried to programmatically bring it back home in a simulated snap back animation but so far no luck. Will try some more.

Have you tried this? http://docs.coronalabs.com/daily/api/type/ScrollViewWidget/scrollTo.html

Thanks for that. Will give that one a go. I am able to simulate the snap effect using the following 

 for p = 60, 0, -1 do scrollView:scrollToPosition({x= p, time=500}) end

How ever when this is tacked onto the end of another ‘finger’ induced snap it gets ignored. I will try the scrollTo and see if I can get anywhere with it. 

In case you’re wondering what I’m trying to do… I am setting my business app to go from one record to another with horizontal scrolls or swipes on the details page. I have it all working but the visual effect is not pleasing. Once you pull the scrollview to the right and let go it snaps back and gets replaced with the new record. I want to let the new record snap in from the other direction so that it looks like a new record coming in from the direction you pulled the original record. Apologies if this is not very clear. 

Maybe put a short timer delay in?

Definitely. I put the long one in to make the effect really obvious. It needs to be shorter to be more like the widget snap.