Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make a swipe transition? #3

Closed
davidmarinangeli opened this issue Mar 22, 2018 · 5 comments
Closed

How can I make a swipe transition? #3

davidmarinangeli opened this issue Mar 22, 2018 · 5 comments

Comments

@davidmarinangeli
Copy link

davidmarinangeli commented Mar 22, 2018

Hello!

I really like your library and I'm trying to develop a transition like the weather app on your Readme: how could I make an up/down swipe?

I've tried with this but the result is VERY BAD. Do you know where I can find some examples? Thanks.
var screenSize = size.y screen.setOnTouchListener { v, event -> when (event.action) { MotionEvent.ACTION_DOWN -> { oldY = event.y true } MotionEvent.ACTION_MOVE -> { transition.setProgress((event.y - oldY)/screenSize) true } else -> { true } } }

@radoyankov
Copy link
Collaborator

radoyankov commented Mar 22, 2018

Which part exactly looks bad? If you are trying to set the touch listener on the element you are resizing ("screen") you will get a weird twitch on the view. If this is your problem, try setting the touch listener on another view, one which is static (I usually set it on the root one).

@davidmarinangeli
Copy link
Author

screen is the static/root one (the constraintlayout). The result is the disaster you can see down below. : \

https://photos.app.goo.gl/VTdkIDg4JR1itcqe2

@radoyankov
Copy link
Collaborator

Before you create your Transitioner object you have to wait for the screen and the views to be drawn. I recommend placing it in a layout listener or, like the example shows, to add a small delay before creating the object.

@davidmarinangeli
Copy link
Author

Ok I create a layout listener and it works, but the animation in REALLY fast, I hope to adjust it by my own. Thanks a lot!

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

No branches or pull requests

2 participants