geftimov/android-viewpager-transformers

Buttons on the back are clickable in FlipHorizontalTransformer

hshahdoost opened this issue · 1 comments

I'm working on a flashcard app, In which each flashcard have two sides, on the front there is a word and on the back there is the translation and two buttons (Correct & Incorrect).
My problem is that the Buttons are accessible on the front side of the card when I pick FlipHorizontalTransformer. When I change my transformer to something else like RotateDownTransformer it works just fine.

device-2017-05-28-182726

Just found the reason why this happens, it's all because of the setAlpha method, it only make the back page invisible but keeps the functionality. I replaced it with setVisibility and the problem was solved. I'm going to send a pull request which solves this problem.

public class FlipHorizontalTransformer extends BaseTransformer {

	@Override
	protected void onTransform(View view, float position) {
		final float rotation = 180f * position;
               // this should be replaced with setVisibitlity
		view.setAlpha(rotation > 90f || rotation < -90f ? 0 : 1); 

		view.setPivotX(view.getWidth() * 0.5f);
		view.setPivotY(view.getHeight() * 0.5f);
		view.setRotationY(rotation);
	}

}