GithubHelp home page GithubHelp logo

Comments (9)

BakerJQ avatar BakerJQ commented on May 14, 2024

You can rewrite the setStyle3() method in MainActivity, and change the setTransformerToBack into this, which is similar to DefaultTransformerToFront, but reverse the rotationX movement:

mCardView.setTransformerToBack(new AnimationTransformer() {
            @Override
            public void transformAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
                int positionCount = fromPosition - toPosition;
                float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);
                view.setScaleX(scale);
                view.setScaleY(scale);
                view.setRotationX(fraction == 1 ? 0 : 180 * fraction);
                if (fraction < 0.5) {
                    view.setTranslationY(-cardHeight * (0.8f - scale) * 0.5f - cardWidth * 0.02f
                            * fromPosition - cardHeight * fraction);
                } else {
                    view.setTranslationY(-cardHeight * (0.8f - scale) * 0.5f - cardWidth * (0.02f *
                            fromPosition - 0.02f * fraction * positionCount) - cardHeight * (1 - fraction));
                }
            }

            @Override
            public void transformInterpolatedAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
            }
        });

from android-infinitecards.

BakerJQ avatar BakerJQ commented on May 14, 2024

Below is the total view of setStyle3() method after rewrite:
image

from android-infinitecards.

BakerJQ avatar BakerJQ commented on May 14, 2024

You can test by press "change" button once and then press "next" button, which was swinging out to the side before rewrite. Hope this can help you.

from android-infinitecards.

Androneilz avatar Androneilz commented on May 14, 2024

Fantastic, that's perfect, thanks so much.

Another question if it's ok: How can I alter the amount of overlap on the cards behind the front one? I'd like more of each card to be visible, so that the title of my item can be seen be the user.

from android-infinitecards.

BakerJQ avatar BakerJQ commented on May 14, 2024

In this case, you'll need to recalculate the TranslationY in each Transformer.
If I understand your question correctly, try add the code below at the end of onCreate() method:

mCardView.setTransformerAnimAdd(new AnimationTransformer() {
            @Override
            public void transformAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
                fromPosition = toPosition + 1;
                int positionCount = fromPosition - toPosition;
                float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);
                view.setScaleX(scale);
                view.setScaleY(scale);
                view.setTranslationY(-cardHeight * (0.8f - scale) * 0.5f - cardWidth * (0.05f *
                        fromPosition - 0.05f * fraction * positionCount));
                view.setAlpha(fraction);
            }

            @Override
            public void transformInterpolatedAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {

            }
        });

from android-infinitecards.

BakerJQ avatar BakerJQ commented on May 14, 2024

image

from android-infinitecards.

Androneilz avatar Androneilz commented on May 14, 2024

Unfortunately, that method isn't public, I can't compile that!

from android-infinitecards.

BakerJQ avatar BakerJQ commented on May 14, 2024

Yes you can. But what you need to do is not to modify the code in DefaultTransformerXXX, but to customize your own AnimationTransformer and call setTransformerXXX method of the InfiniteCardView.

from android-infinitecards.

Androneilz avatar Androneilz commented on May 14, 2024

Thanks. I had to import the code directly into my project, and change all the default transformers. I've made a constant for the top gap, so it's now configurable.

from android-infinitecards.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.