-
Notifications
You must be signed in to change notification settings - Fork 451
/
Copy pathWoWoPositionAnimation.java
50 lines (40 loc) · 1.54 KB
/
WoWoPositionAnimation.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.nightonke.wowoviewpager.Animation;
import android.animation.TimeInterpolator;
import android.view.View;
/**
* Created by Weiping Huang at 18:13 on 2017/3/29
* For Personal Open Source
* Contact me at [email protected] or [email protected]
* For more projects: https://github.com/Nightonke
*
* Animation to change 2D-position of a view.
*/
public class WoWoPositionAnimation extends XYPageAnimation {
private WoWoPositionAnimation(int page, float startOffset, float endOffset, int ease, TimeInterpolator interpolator, boolean useSameEaseEnumBack, float fromX, float fromY, float toX, float toY) {
super(page, startOffset, endOffset, ease, interpolator, useSameEaseEnumBack, fromX, fromY, toX, toY);
}
@Override
protected void toStartState(View view) {
view.setX(fromX);
view.setY(fromY);
}
@Override
protected void toMiddleState(View view, float offset) {
view.setX(fromX + (toX - fromX) * offset);
view.setY(fromY + (toY - fromY) * offset);
}
@Override
protected void toEndState(View view) {
view.setX(toX);
view.setY(toY);
}
public static Builder builder() {
return new Builder();
}
public static class Builder extends XYPageAnimation.Builder<WoWoPositionAnimation.Builder> {
public WoWoPositionAnimation build() {
checkUninitializedAttributes();
return new WoWoPositionAnimation(page, startOffset, endOffset, ease, interpolator, useSameEaseEnumBack, fromX, fromY, toX, toY);
}
}
}