|
@@ -5,6 +5,8 @@ import android.animation.ObjectAnimator;
|
5
|
5
|
import android.view.View;
|
6
|
6
|
import android.view.animation.OvershootInterpolator;
|
7
|
7
|
|
|
8
|
+import com.reactnativenavigation.params.SlidingOverlayParams.Position;
|
|
9
|
+
|
8
|
10
|
import static android.view.View.TRANSLATION_Y;
|
9
|
11
|
|
10
|
12
|
public class PeekingAnimator {
|
|
@@ -14,12 +16,12 @@ public class PeekingAnimator {
|
14
|
16
|
|
15
|
17
|
private final Animator animator;
|
16
|
18
|
|
17
|
|
- public PeekingAnimator(View view, final boolean show) {
|
18
|
|
- final int heightPixels = view.getLayoutParams().height;
|
|
19
|
+ public PeekingAnimator(View view, Position position, final boolean show) {
|
|
20
|
+ final int offsetPixels = view.getLayoutParams().height * (position == Position.Top ? -1 : 1);
|
19
|
21
|
|
20
|
22
|
this.animator = show ?
|
21
|
|
- createSlideInAnimator(view, heightPixels) :
|
22
|
|
- createSlideOutAnimator(view, heightPixels);
|
|
23
|
+ createSlideInAnimator(view, offsetPixels) :
|
|
24
|
+ createSlideOutAnimator(view, offsetPixels);
|
23
|
25
|
}
|
24
|
26
|
|
25
|
27
|
public void addListener(Animator.AnimatorListener listener) {
|
|
@@ -30,8 +32,9 @@ public class PeekingAnimator {
|
30
|
32
|
animator.start();
|
31
|
33
|
}
|
32
|
34
|
|
33
|
|
- private ObjectAnimator createSlideInAnimator(View view, int heightPixels) {
|
34
|
|
- view.setTranslationY(-heightPixels);
|
|
35
|
+ private ObjectAnimator createSlideInAnimator(View view, int offset) {
|
|
36
|
+
|
|
37
|
+ view.setTranslationY(offset);
|
35
|
38
|
|
36
|
39
|
ObjectAnimator slideIn = ObjectAnimator.ofFloat(view, TRANSLATION_Y, 0);
|
37
|
40
|
slideIn.setDuration(SLIDE_IN_DURATION);
|
|
@@ -39,8 +42,8 @@ public class PeekingAnimator {
|
39
|
42
|
return slideIn;
|
40
|
43
|
}
|
41
|
44
|
|
42
|
|
- private ObjectAnimator createSlideOutAnimator(View view, int heightPixels) {
|
43
|
|
- ObjectAnimator slideOut = ObjectAnimator.ofFloat(view, TRANSLATION_Y, -heightPixels);
|
|
45
|
+ private ObjectAnimator createSlideOutAnimator(View view, int offset) {
|
|
46
|
+ ObjectAnimator slideOut = ObjectAnimator.ofFloat(view, TRANSLATION_Y, offset);
|
44
|
47
|
slideOut.setDuration(SLIDE_OUT_DURATION);
|
45
|
48
|
return slideOut;
|
46
|
49
|
}
|