ScrollView destination position

Hello, 

I have a scrollView thats has width of the screen size.

Lets say the amount of elements in it maks total width of 10 x screen size.

So in total the scrollView content has width 10x scrollView.

Now I did set friction = 0.96 (so it scrollsFurthers)

I was wonder If at the ended phase of scrollView in scrollListener, or in any other way.

I am able to get destination position at which scrollView will stop.

To simplfy it I want to know exact position that scrollView would stop if there is no more any user action, before it actually stops.

What I want to avoid:

  1. Write own scrollView from scratch.

  2. Edit source of corona files.

Is is possible with current state of corona?

Thanks in advance.

Hi @dirindon,

Do you want to detect in advance where the view will “stop moving” based on whatever variable amount of swipe the user puts on it? Or do you want to effectively trigger an event when the movement slows down or stops?

Brent

Well any of that would solve my problem. 

I was wondering if there is any built in way to do so.

Adding enterFrame listener will allow me to detect when scrollView is slowing down,

But actually detecting in advance when scrollView would stop moving would be better for me.

I guess its determined right in the ended phase of scrollViewListener somehow, didn’t yet discovered how.

Hi @dirindon,

The “ended” phase is associated with the user’s touch on the ScrollView, so that won’t be triggered when the movement slows down to a stop on its own accord.

I think your best bet to pre-determine where the view will stop (or at least close) would be to calculate it via math formulas. Internally, the movement uses the “easing.outQuad” transition algorithm which is based on Robert Penner’s easing functions. If you can calculate the math, perhaps using resources here, you can probably pre-determine where the the view will stop, no matter what amount of flick speed the user puts on it.

Best regards,

Brent

I did manage to solve the problem with enter frame listener by comparing delta, of X in every frame, if in at least 20 continous frames its lower then let say 5, I know that scrollView is slowing down. Not perfect solution but works very good for me. 

Anyway thanks for help :slight_smile:

Hi @dirindon,

Do you want to detect in advance where the view will “stop moving” based on whatever variable amount of swipe the user puts on it? Or do you want to effectively trigger an event when the movement slows down or stops?

Brent

Well any of that would solve my problem. 

I was wondering if there is any built in way to do so.

Adding enterFrame listener will allow me to detect when scrollView is slowing down,

But actually detecting in advance when scrollView would stop moving would be better for me.

I guess its determined right in the ended phase of scrollViewListener somehow, didn’t yet discovered how.

Hi @dirindon,

The “ended” phase is associated with the user’s touch on the ScrollView, so that won’t be triggered when the movement slows down to a stop on its own accord.

I think your best bet to pre-determine where the view will stop (or at least close) would be to calculate it via math formulas. Internally, the movement uses the “easing.outQuad” transition algorithm which is based on Robert Penner’s easing functions. If you can calculate the math, perhaps using resources here, you can probably pre-determine where the the view will stop, no matter what amount of flick speed the user puts on it.

Best regards,

Brent

I did manage to solve the problem with enter frame listener by comparing delta, of X in every frame, if in at least 20 continous frames its lower then let say 5, I know that scrollView is slowing down. Not perfect solution but works very good for me. 

Anyway thanks for help :slight_smile: