Przeglądaj źródła

Some work on animation config in the playground app

Split animation config in playground to custom animations and slow animations
Guy Carmeli 4 lat temu
rodzic
commit
8f2f353d62
2 zmienionych plików z 13 dodań i 9 usunięć
  1. 12
    9
      playground/src/commons/Options.js
  2. 1
    0
      playground/src/flags.js

+ 12
- 9
playground/src/commons/Options.js Wyświetl plik

@@ -5,10 +5,11 @@ const height = Math.round(Dimensions.get('window').height);
5 5
 const width = Math.round(Dimensions.get('window').width);
6 6
 console.log('guyca', `height: ${height} width: ${width}`);
7 7
 const {
8
+  useCustomAnimations,
8 9
   useSlowOpenScreenAnimations,
9 10
   useSlideAnimation
10 11
 } = require('../flags');
11
-const SHOW_DURATION = 310 * 2.5;
12
+const SHOW_DURATION = 250 * (useSlowOpenScreenAnimations ? 2.5 : 1);
12 13
 
13 14
 const setDefaultOptions = () => Navigation.setDefaultOptions({
14 15
   layout: {
@@ -26,8 +27,8 @@ const setDefaultOptions = () => Navigation.setDefaultOptions({
26 27
   animations: {
27 28
     ...useSlideAnimation ?
28 29
         slideAnimations :
29
-        useSlowOpenScreenAnimations ?
30
-          slowOpenScreenAnimations :
30
+        useCustomAnimations ?
31
+          customAnimations :
31 32
           {}
32 33
   },
33 34
   modalPresentationStyle: 'fullScreen'
@@ -65,7 +66,7 @@ const slideAnimations = {
65 66
   }
66 67
 }
67 68
 
68
-const slowOpenScreenAnimations = {
69
+const customAnimations = {
69 70
   showModal: {
70 71
     waitForRender: true,
71 72
     translationY: {
@@ -77,7 +78,7 @@ const slowOpenScreenAnimations = {
77 78
     alpha: {
78 79
       from: 0.65,
79 80
       to: 1,
80
-      duration: SHOW_DURATION * 0.5,
81
+      duration: SHOW_DURATION * 0.7,
81 82
       interpolation: 'accelerate'
82 83
     }
83 84
   },
@@ -85,7 +86,7 @@ const slowOpenScreenAnimations = {
85 86
     translationY: {
86 87
       from: 0,
87 88
       to: height,
88
-      duration: SHOW_DURATION * 0.8,
89
+      duration: SHOW_DURATION * 0.9,
89 90
     },
90 91
     
91 92
   },
@@ -93,14 +94,16 @@ const slowOpenScreenAnimations = {
93 94
     waitForRender: true,
94 95
     content: {
95 96
       alpha: {
96
-        from: 0.6,
97
+        from: 0.65,
97 98
         to: 1,
98
-        duration: SHOW_DURATION,
99
+        duration: SHOW_DURATION * 0.7,
100
+        interpolation: 'accelerate'
99 101
       },
100 102
       translationY: {
101 103
         from: height * 0.3,
102 104
         to: 0,
103 105
         duration: SHOW_DURATION,
106
+        interpolation: 'decelerate'
104 107
       }
105 108
     }
106 109
   },
@@ -114,7 +117,7 @@ const slowOpenScreenAnimations = {
114 117
       translationY: {
115 118
         from: 0,
116 119
         to: height * 0.7,
117
-        duration: SHOW_DURATION,
120
+        duration: SHOW_DURATION * 0.9,
118 121
       }
119 122
     }
120 123
   }

+ 1
- 0
playground/src/flags.js Wyświetl plik

@@ -1,5 +1,6 @@
1 1
 module.exports = {
2 2
   showTextInputToTestKeyboardInteraction: false,
3
+  useCustomAnimations: false,
3 4
   useSlowOpenScreenAnimations: false,
4 5
   useSlideAnimation: false
5 6
 };