Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

feature: Fling functionality #2

Closed
quintos opened this issue Oct 26, 2012 · 10 comments
Closed

feature: Fling functionality #2

quintos opened this issue Oct 26, 2012 · 10 comments
Assignees

Comments

@quintos
Copy link

quintos commented Oct 26, 2012

Hi,

Thank you for sharing this code. I think it's very well done.

This is more of a feature request than an issue:
I would be nice if users could fling the pages. At this time its only possible to move the page over the middle and when over the middle, it falls over. But i thing it's a better user experience to be able to fling it. When you use Flipboard, you can flip through the pages very smoothly by doing very short flings.

Thanks!

@openaphid
Copy link
Owner

I'm afraid that I can't reproduce the issue. Maybe I miss the point.

During my test, the page didn't fall over automatically as long as my finger didn't leave the screen.

@quintos
Copy link
Author

quintos commented Oct 26, 2012

No, what i meant is, the ability to "fling" it. (Flinging being that a animation continues at a degrading speed (or the same) after the finger is released. or something like that..)

This is the experience in the Flipboard implementation:
I fling it up or down but release it before it reaches the middle. And because of the speed/momentum it crosses the middle and falls over without my finger attached. (This is how it's perceived)

What i'm experiencing with your implementation is, if i release my finger before the page reaches the middle, it will always fall back. I need to keep my finger attached until it over the middle. In other words i need to take it over the middle with my finger and i can not fling it over the middle.

I don;t know if you have Flipboard available to have a look but you'll notice that you can give pages a very small push and that will still trigger the page to flip over by itself.

Is this not how you experience it?

@openaphid
Copy link
Owner

Now I got it.

A velocity tracker is required to detect it. We'll add the support later with the event listener too.

Thanks

@ghost ghost assigned openaphid Oct 26, 2012
@quintos
Copy link
Author

quintos commented Oct 27, 2012

cool

@iPaulPro
Copy link

@openaphid The Flipboard component actually "snaps" to the direction that the finger last moved. Velocity does not matter, and doesn't need to be tracked.

E.g. If the last touch movement was negative (bottom to top), always flip to the next page, regardless of how the gesture started, or how fast the finger was moving.

I'd love to see this added, as it allows the user to "fling" through pages in an intuitive way. I am looking into the source now, to attempt to implement it myself. It appears that the key is to alter FlipCards.rotateBy() and line forward = angle >= 90; in FlipCards.handleTouchEvent(). Any help is greatly appreciated (as it will take me time to familiarize myself).

Awesome work!

@iPaulPro
Copy link

So making the change I describe above is very simple. In FlipCards.handleTouchEvent():

In MotionEvent.ACTION_UP

remove forward = angle >= 90;

then in MotionEvent.ACTION_MOVE

add forward = delta > 0;

The only issue this causes is that the first page is no longer bound to the MAX_TIP_ANGLE. I will make a pull request if I get that fixed.

@iPaulPro
Copy link

So the only other change I had to make to support the MAX_TIP_ANGLE boundary was to add

if (frontCards.getIndex() == -1)
    forward = true;
else if (backCards.getIndex() == -1) 
    forward = false;

where forward = angle >= 90; used to be (in MotionEvent.ACTION_UP).

@openaphid Let me know if there is an issue with this implementation. I have submitted a pull request: #10.

@VAdaihiep
Copy link

@iPaulPro Thanks in advance, I just use your code to fling and it works perfectly. But I seen slightly slower while backward page, sometimes it does NOT perform flip animation. Please tell me how to make it smoother like forward page?
Hope to hear from you soon. Thank you!

@openaphid
Copy link
Owner

@iPaulPro Thanks for your contribution.

@VAdaihiep A new issue is created to address the problem you have.

@openaphid
Copy link
Owner

@VAdaihiep Please try the updated APK to see if it fixes the issue: https://github.com/openaphid/android-flip/blob/develop/FlipView/Demo/APK/Aphid-FlipView-Demo.apk

And you could follow it up in issue #17

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants