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

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

@@ -8,6 +8,7 @@ import android.view.Menu;
8 8
 import android.view.MenuInflater;
9 9
 
10 10
 import com.reactnativenavigation.R;
11
+import com.reactnativenavigation.animation.HideOnScrollAnimator;
11 12
 import com.reactnativenavigation.core.Button;
12 13
 
13 14
 import java.util.List;
@@ -17,10 +18,12 @@ public class TitleBar extends Toolbar {
17 18
     private Menu menu;
18 19
     private ActionMenuView actionMenuView;
19 20
     private boolean hideOnScroll = false;
21
+    private HideOnScrollAnimator hideOnScrollAnimator;
20 22
 
21 23
     public TitleBar(Context context) {
22 24
         super(context);
23 25
         createMenu();
26
+
24 27
     }
25 28
 
26 29
     private void createMenu() {
@@ -49,7 +52,14 @@ public class TitleBar extends Toolbar {
49 52
 
50 53
     public void onScrollChanged(ScrollDirectionListener.Direction direction) {
51 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
 }