Browse Source

animator on scroll

Daniel Zlotin 8 years ago
parent
commit
8801e30d2e

+ 0
- 2
android/app/src/main/java/com/reactnativenavigation/animation/HideOnScrollAnimator.java View File

3
 import android.animation.Animator;
3
 import android.animation.Animator;
4
 import android.animation.AnimatorListenerAdapter;
4
 import android.animation.AnimatorListenerAdapter;
5
 import android.animation.ObjectAnimator;
5
 import android.animation.ObjectAnimator;
6
-import android.support.annotation.NonNull;
7
 import android.support.v4.view.animation.LinearOutSlowInInterpolator;
6
 import android.support.v4.view.animation.LinearOutSlowInInterpolator;
8
 import android.view.View;
7
 import android.view.View;
9
 
8
 
82
         return state == State.Hidden || state == State.AnimateHide;
81
         return state == State.Hidden || state == State.AnimateHide;
83
     }
82
     }
84
 
83
 
85
-    @NonNull
86
     private ObjectAnimator createAnimator(final boolean show) {
84
     private ObjectAnimator createAnimator(final boolean show) {
87
         ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, show ? shownEndValue : hiddenEndValue);
85
         ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, show ? shownEndValue : hiddenEndValue);
88
         animator.setDuration(DURATION);
86
         animator.setDuration(DURATION);

+ 11
- 1
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java View File

8
 import android.view.MenuInflater;
8
 import android.view.MenuInflater;
9
 
9
 
10
 import com.reactnativenavigation.R;
10
 import com.reactnativenavigation.R;
11
+import com.reactnativenavigation.animation.HideOnScrollAnimator;
11
 import com.reactnativenavigation.core.Button;
12
 import com.reactnativenavigation.core.Button;
12
 
13
 
13
 import java.util.List;
14
 import java.util.List;
17
     private Menu menu;
18
     private Menu menu;
18
     private ActionMenuView actionMenuView;
19
     private ActionMenuView actionMenuView;
19
     private boolean hideOnScroll = false;
20
     private boolean hideOnScroll = false;
21
+    private HideOnScrollAnimator hideOnScrollAnimator;
20
 
22
 
21
     public TitleBar(Context context) {
23
     public TitleBar(Context context) {
22
         super(context);
24
         super(context);
23
         createMenu();
25
         createMenu();
26
+
24
     }
27
     }
25
 
28
 
26
     private void createMenu() {
29
     private void createMenu() {
49
 
52
 
50
     public void onScrollChanged(ScrollDirectionListener.Direction direction) {
53
     public void onScrollChanged(ScrollDirectionListener.Direction direction) {
51
         if (hideOnScroll) {
54
         if (hideOnScroll) {
52
-            //TODO animate hide/show
55
+            if (hideOnScrollAnimator == null) {
56
+                createScrollAnimator();
57
+            }
58
+            hideOnScrollAnimator.onScrollChanged(direction);
53
         }
59
         }
54
     }
60
     }
61
+
62
+    private void createScrollAnimator() {
63
+        hideOnScrollAnimator = new HideOnScrollAnimator(this, HideOnScrollAnimator.HideDirection.Up, getHeight());
64
+    }
55
 }
65
 }