jfeinstein10 / JazzyViewPager

An easy to use ViewPager that adds an awesome set of custom swiping animations. Just change your ViewPagers to JazzyViewPagers, two more steps, and you're good to go!
Apache License 2.0
2.67k stars 814 forks source link

Scaled Flip animation #45

Open jurajjarabek opened 10 years ago

jurajjarabek commented 10 years ago

Hey guys please help, I've been stuck for many days with this: I am using Horizontal flip Animation. To me, animation doesn't seem perfect because the edges of the view are coming out of the screen while rotating it. Anyway, what I am trying to do is to scale the view while rotating it - make it smaller during the rotation. To me It seems, that while rotating the view scale doesn't work at all. When I don't use rotation scale is working correctly. Please help ! Here is my code:

    if (mState != State.IDLE) {
        if (left != null) {
            manageLayer(left, true);
            mRot = -180.0f * positionOffset;

            if (mRot < -90.0f) {
                left.setVisibility(View.INVISIBLE);
            } else {
                if (left.getVisibility() == View.INVISIBLE)
                    left.setVisibility(View.VISIBLE);
                mTrans = positionOffsetPixels;
                mScale = ZOOM_MAX + (1-ZOOM_MAX)*(1-positionOffset);

                ViewHelper.setPivotX(left, left.getMeasuredWidth()*0.5f);
                ViewHelper.setPivotY(left, left.getMeasuredHeight()*0.5f);
                ViewHelper.setScaleX(left, mScale);
                ViewHelper.setScaleY(left, mScale);
                ViewHelper.setTranslationX(left, mTrans);
                ViewHelper.setRotationY(left, mRot);
            }
        }

        if (right != null) {
            manageLayer(right, true);
            mRot = 180.0f * (1-positionOffset);

            if (mRot > 90.0f) {
                right.setVisibility(View.INVISIBLE);
            } else {
                if (right.getVisibility() == View.INVISIBLE)
                    right.setVisibility(View.VISIBLE);
                mTrans = -getWidth()-getPageMargin()+positionOffsetPixels;
                mScale = ZOOM_MAX + (1-ZOOM_MAX)*positionOffset;

                ViewHelper.setPivotX(right, right.getMeasuredWidth()*0.5f);
                ViewHelper.setPivotY(right, right.getMeasuredHeight()*0.5f);
                ViewHelper.setScaleX(right, mScale);
                ViewHelper.setScaleY(right, mScale);
                ViewHelper.setTranslationX(right, mTrans);
                ViewHelper.setRotationY(right, mRot);
            }
        }
    }
jurajjarabek commented 10 years ago

anybody ?