-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
122 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
ecardflow/src/main/java/moe/codeest/ecardflow/mode/CrossMoveAnimMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package moe.codeest.ecardflow.mode; | ||
|
||
import android.widget.ImageView; | ||
|
||
/** | ||
* Created by codeest on 2017/2/25. | ||
*/ | ||
|
||
public class CrossMoveAnimMode implements AnimMode { | ||
|
||
private static final float DEFAULT_MOVE_SCALE = 1.3f; | ||
private float mScale; | ||
|
||
public CrossMoveAnimMode() { | ||
this.mScale = DEFAULT_MOVE_SCALE; | ||
} | ||
|
||
public CrossMoveAnimMode(float mScale) { | ||
this.mScale = mScale; | ||
} | ||
|
||
@Override | ||
public void transformPage(ImageView ivBg, float position, int direction) { | ||
ivBg.setScaleX(mScale); | ||
ivBg.setScaleY(mScale); | ||
float totalMoveWidth = ivBg.getWidth() * ((mScale - 1) / 2); | ||
int lastPosition = Math.round(position); | ||
float mFraction; | ||
if (lastPosition % 2 == 0) { | ||
mFraction = -1 * (float) Math.sin(Math.PI * position); | ||
} else { | ||
mFraction = (float) Math.sin(Math.PI * position); | ||
} | ||
ivBg.setTranslationY(totalMoveWidth * mFraction); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
ecardflow/src/main/java/moe/codeest/ecardflow/mode/ScaleAnimMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package moe.codeest.ecardflow.mode; | ||
|
||
import android.widget.ImageView; | ||
|
||
/** | ||
* Created by codeest on 2017/2/25. | ||
*/ | ||
|
||
public class ScaleAnimMode implements AnimMode { | ||
|
||
private static final int DEFAULT_SCALE_RATE = 1; | ||
private int mScaleRate; | ||
|
||
public ScaleAnimMode() { | ||
this.mScaleRate = DEFAULT_SCALE_RATE; | ||
} | ||
|
||
public ScaleAnimMode(int scaleRate) { | ||
this.mScaleRate = scaleRate; | ||
} | ||
|
||
@Override | ||
public void transformPage(ImageView ivBg, float position, int direction) { | ||
float mFraction = mScaleRate * (float) Math.abs(Math.sin(Math.PI * position)); | ||
ivBg.setScaleX(1 + mFraction); | ||
ivBg.setScaleY(1 + mFraction); | ||
} | ||
} |