airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.49k stars 733 forks source link

carousel cann't scroll to first position after scrolled once #328

Closed JasonHezz closed 6 years ago

JasonHezz commented 6 years ago

sample link

step to reduce:

carousel will have a bounce when reach first position and auto scroll a offset happened in lands landscape

elihart commented 6 years ago

I believe this is the behavior of the default LinearSnapHelper. Something similar can be observed in the epoxy sample app.

Given that this snap helper is the standard behavior provided by google I didn't look into it too much yet, but it would be a good thing to investigate.

In the meantime can set your own default snap helper to change the snapping behavior, or set it to no snap helper.

Carousel.setDefaultGlobalSnapHelperFactory(null to disable or a custom value if you want)
elihart commented 6 years ago

I'm considering using a library such as https://github.com/rubensousa/RecyclerViewSnap as the default, but I want to be a little careful about including other libraries.

JasonHezz commented 6 years ago

Thanks, it works , but why SnapHelperFactory is abstract static class

vikrama commented 6 years ago

https://stackoverflow.com/questions/44766186/linearsnaphelper-doesnt-snap-on-edge-items-of-recyclerview

This sort of explains this problem with LinearSnapHelper

berendjan commented 3 years ago

https://github.com/rubensousa/RecyclerViewSnap I used the above mentioned library in the onBind callback, and set the global default to null. (else it will start to dance between the 2 snapping strategies)

Carousel.setDefaultGlobalSnapHelperFactory(null)
carousel {
    id("some_id")
    numViewsToShowOnScreen(2.2f)
    models(listOfModels)
    onBind{ _, recyclerView, _ ->
        GravitySnapHelper(Gravity.START)
            .attachToRecyclerView(recyclerView)
    }
}
Draketheb4dass commented 3 years ago
numViewsToShowOnScreen(2.2f)

Mine is still dancing... I'm confuse

ubarua123 commented 2 years ago

I forgot to add this Carousel.setDefaultGlobalSnapHelperFactory(null) and mine were dancing left and right. The above solution works.