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

Control the speed of scrolling... #79

Open
jpvs0101 opened this issue Jun 26, 2018 · 5 comments
Open

Control the speed of scrolling... #79

jpvs0101 opened this issue Jun 26, 2018 · 5 comments
Labels

Comments

@jpvs0101
Copy link

Smooth scroll is awesome! (Especially with zoom effect).
But in some cases, better use normal scrolling behaviour!
Is there any workaround to make items scroll in normal speed (or control the speed)?

@mig35
Copy link
Member

mig35 commented Jun 26, 2018

@jpvs0101
I don't know what do you mean by normal scrolling, but the way how items are changed is controlling here: https://github.com/Azoft/CarouselLayoutManager/blob/master/CarouselLayoutManager/carousel/src/main/java/com/azoft/carousellayoutmanager/CarouselZoomPostLayoutListener.java

If it is not an answer, please give me a better explanation of your question.

@jpvs0101
Copy link
Author

jpvs0101 commented Jun 26, 2018

@mig35

I mean, control over the speed of scroll!

To be more precise,
i want to control the below method in CarouselLayoutManager.java

 @Override
    public int scrollHorizontallyBy(final int dx, final RecyclerView.Recycler recycler, final RecyclerView.State state) {
        if (VERTICAL == mOrientation) {
            return 0;
        }
        return scrollBy(dx, recycler, state);
    }

how to increase the speed of scroll?

@mig35
Copy link
Member

mig35 commented Jul 10, 2018

@jpvs0101 sorry for a long answer.
Basically LayoutManager is not controlling the scrolling speed. The only method where I'm using a scoller is

public void smoothScrollToPosition(@NonNull final RecyclerView recyclerView, @NonNull final RecyclerView.State state, final int position) {
        final LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
            @Override
            public int calculateDyToMakeVisible(final View view, final int snapPreference) {
                if (!canScrollVertically()) {
                    return 0;
                }

                return getOffsetForCurrentView(view);
            }

            @Override
            public int calculateDxToMakeVisible(final View view, final int snapPreference) {
                if (!canScrollHorizontally()) {
                    return 0;
                }
                return getOffsetForCurrentView(view);
            }
        };
        linearSmoothScroller.setTargetPosition(position);
        startSmoothScroll(linearSmoothScroller);
    }

You can override it an use any scoller that you want. Note that this method will be called from CenterScrollListener class.

Other scrolling things are controlled only from the RecyclerView.
Basically I can add some multiplier for such events, but I don't think that we need them. If you really need it, you can override scrollHorizontallyBy and scrollVerticallyBy methods and pass smaller/bigger dx and dy values.. may be it will help you

@mig35 mig35 added the question label Jul 10, 2018
@jpvs0101
Copy link
Author

jpvs0101 commented Jul 10, 2018 via email

@arpitbandil
Copy link

I want to achieve to same scroll speed, so @jpvs0101 Can you please share your answer with us?

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

No branches or pull requests

3 participants