Selaa lähdekoodia

enable animation by default; bump version number to 0.2.1

iou90 7 vuotta sitten
vanhempi
commit
2c77738d36
4 muutettua tiedostoa jossa 25 lisäystä ja 24 poistoa
  1. 6
    1
      README.md
  2. 13
    18
      autoHeightWebView/index.android.js
  3. 5
    4
      autoHeightWebView/index.ios.js
  4. 1
    1
      package.json

+ 6
- 1
README.md Näytä tiedosto

@@ -14,10 +14,15 @@ An auto height webview for React Native.
14 14
 
15 15
 ```javascript
16 16
 <AutoHeightWebView
17
+    onHeightUpdated={height => console.log(height)},
18
+    // offset of rn webview margin 
19
+    heightOffset={5}
20
+    // default width is the width of screen
21
+    style={customStyle}
22
+    // enable animation by default
17 23
     enableAnimation={true},
18 24
     // only works on enable animation
19 25
     animationDuration={255},
20
-    onHeightUpdated={height => console.log(height)}
21 26
     // or uri
22 27
     source={{ html: `<p style="font-weight: 400;font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;">Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. <span style="background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));">If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with “moving”. I’d also use the tags “pets”, “marriage”, “career change”, and “travel tips”.</span></p>` }}
23 28
     // use local or remote files

+ 13
- 18
autoHeightWebView/index.android.js Näytä tiedosto

@@ -74,14 +74,6 @@ export default class AutoHeightWebView extends ImmutableComponent {
74 74
         this.setState({ script: currentScript });
75 75
     }
76 76
 
77
-    // componentDidUpdate(prevProps, prevState) {
78
-    //     // redisplay webview when changing source
79
-    //     if (this.state.isChangingSource) {
80
-    //         this.startInterval();
81
-    //         this.setState({ isChangingSource: false });
82
-    //     }
83
-    // }
84
-
85 77
     componentWillUnmount() {
86 78
         this.stopInterval();
87 79
         if (IsBelowKitKat) {
@@ -94,14 +86,6 @@ export default class AutoHeightWebView extends ImmutableComponent {
94 86
         this.onMessage(body.message);
95 87
     }
96 88
 
97
-    postMessage(data) {
98
-        UIManager.dispatchViewManagerCommand(
99
-            findNodeHandle(this.webview),
100
-            UIManager.RCTAutoHeightWebView.Commands.postMessage,
101
-            [String(data)]
102
-        );
103
-    };
104
-
105 89
     // below kitkat
106 90
     sendToWebView(message) {
107 91
         UIManager.dispatchViewManagerCommand(
@@ -111,6 +95,14 @@ export default class AutoHeightWebView extends ImmutableComponent {
111 95
         );
112 96
     }
113 97
 
98
+    postMessage(data) {
99
+        UIManager.dispatchViewManagerCommand(
100
+            findNodeHandle(this.webview),
101
+            UIManager.RCTAutoHeightWebView.Commands.postMessage,
102
+            [String(data)]
103
+        );
104
+    };
105
+
114 106
     startInterval() {
115 107
         this.finishInterval = false;
116 108
         this.interval = setInterval(() => {
@@ -209,11 +201,13 @@ export default class AutoHeightWebView extends ImmutableComponent {
209 201
 }
210 202
 
211 203
 AutoHeightWebView.propTypes = {
212
-    enableAnimation: PropTypes.bool,
213 204
     source: WebView.propTypes.source,
214 205
     onHeightUpdated: PropTypes.func,
215 206
     customScript: PropTypes.string,
216
-    // offset rn webview margin
207
+    enableAnimation: PropTypes.bool,
208
+    // only works on enable animation
209
+    animationDuration: PropTypes.number,
210
+    // offset of rn webview margin
217 211
     heightOffset: PropTypes.number,
218 212
     // baseUrl not work in android 4.3 or below version
219 213
     enableBaseUrl: PropTypes.bool,
@@ -227,6 +221,7 @@ AutoHeightWebView.propTypes = {
227 221
 }
228 222
 
229 223
 AutoHeightWebView.defaultProps = {
224
+    enableAnimation: true,
230 225
     animationDuration: 555,
231 226
     enableBaseUrl: false,
232 227
     heightOffset: 20

+ 5
- 4
autoHeightWebView/index.ios.js Näytä tiedosto

@@ -105,13 +105,13 @@ export default class AutoHeightWebView extends ImmutableComponent {
105 105
 }
106 106
 
107 107
 AutoHeightWebView.propTypes = {
108
-    enableAnimation: PropTypes.bool,
109
-    // only works on enable animation
110
-    animationDuration: PropTypes.number,
111 108
     source: WebView.propTypes.source,
112 109
     onHeightUpdated: PropTypes.func,
113 110
     customScript: PropTypes.string,
114
-    // offset rn webview margin
111
+    enableAnimation: PropTypes.bool,
112
+    // only works on enable animation
113
+    animationDuration: PropTypes.number,
114
+    // offset of rn webview margin
115 115
     heightOffset: PropTypes.number,
116 116
     style: View.propTypes.style,
117 117
     // add web/files... to project root
@@ -123,6 +123,7 @@ AutoHeightWebView.propTypes = {
123 123
 }
124 124
 
125 125
 AutoHeightWebView.defaultProps = {
126
+    enableAnimation: true,
126 127
     animationDuration: 555,
127 128
     heightOffset: 12
128 129
 }

+ 1
- 1
package.json Näytä tiedosto

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-autoheight-webview",
3
-  "version": "0.2.0",
3
+  "version": "0.2.1",
4 4
   "description": "An auto height webview for React Native",
5 5
   "main": "autoHeightWebView",
6 6
   "files": [