package org.wikipedia.page.gallery;

import android.support.v4.view.ViewPager;
import android.view.View;

public class GalleryPagerTransformer implements ViewPager.PageTransformer {
    private static final float MIN_SCALE = 0.5f;
    private static final float ROTATION_DEGREES = 30.0f;

    @Override
    public void transformPage(View view, float position) {
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
        } else if (position <= 0) { // [-1,0]
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            // fade out
            view.setAlpha(1 + position);
            // give it a bit of a rotation
            view.setRotationY(-position * ROTATION_DEGREES);
        } else if (position <= 1) { // (0,1]
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            // fade out
            view.setAlpha(1 - position);
            // give it a bit of a rotation
            view.setRotationY(-position * ROTATION_DEGREES);
        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
        }
    }
}
@@ -224,66 +224,9 @@
 = 0.
-5f;%0A    private static final float ROTATION_DEGREES = 30.0
+9
 f;%0A%0A
@@ -401,16 +401,53 @@
 e left.%0A
+            view.setTranslationX(0);%0A
         
@@ -738,35 +738,55 @@
  // 
-give it a bit of a rot
+keep it in place (undo the default transl
 ation
+)
 %0A   
@@ -806,46 +806,50 @@
 .set
-Rot
+Transl
 ation
-Y(-position * ROTATION_DEGREES
+X(-(view.getWidth() * position)
 );%0A 
@@ -908,334 +908,56 @@
     
-float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));%0A            view.setScaleX(scaleFactor);%0A            view.setScaleY(scaleFactor);%0A            // fade out%0A            view.setAlpha(1 - position);%0A            // give it a bit of a rotation%0A            view.setRotationY(-position * ROTATION_DEGREES);
+// don't do anything to it when it's sliding in.
 %0A   
@@ -1044,16 +1044,53 @@
  right.%0A
+            view.setTranslationX(0);%0A
         

Improve transition between gallery images.