Browse Source

Change the name of scrollableWhenZoomin prop to scrollEnabledWithZoomedin

iou90 5 years ago
parent
commit
5ac5222a8c
5 changed files with 11 additions and 11 deletions
  1. 1
    1
      README.md
  2. 4
    4
      autoHeightWebView/index.js
  3. 4
    4
      autoHeightWebView/utils.js
  4. 1
    1
      demo/App.js
  5. 1
    1
      index.d.ts

+ 1
- 1
README.md View File

62
 | files                        |    -    | `PropTypes.arrayOf(PropTypes.shape({ href: PropTypes.string, type: PropTypes.string, rel: PropTypes.string }))` | Using local or remote files. To add local files: Add files to android/app/src/main/assets/ (depends on baseUrl) on android; add files to web/ (depends on baseUrl) on iOS.                                   |
62
 | files                        |    -    | `PropTypes.arrayOf(PropTypes.shape({ href: PropTypes.string, type: PropTypes.string, rel: PropTypes.string }))` | Using local or remote files. To add local files: Add files to android/app/src/main/assets/ (depends on baseUrl) on android; add files to web/ (depends on baseUrl) on iOS.                                   |
63
 | source                       |    -    |                                               `PropTypes.object`                                                | BaseUrl now contained by source. 'web/' by default on iOS; 'file:///android_asset/' by default on Android or uri.                                                                                            |
63
 | source                       |    -    |                                               `PropTypes.object`                                                | BaseUrl now contained by source. 'web/' by default on iOS; 'file:///android_asset/' by default on Android or uri.                                                                                            |
64
 | scalesPageToFit              |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview which true by default on Android). When scalesPageToFit was enabled, it will apply the scale of the page directly instead of using viewport meta script.    |
64
 | scalesPageToFit              |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview which true by default on Android). When scalesPageToFit was enabled, it will apply the scale of the page directly instead of using viewport meta script.    |
65
-| scrollableWhenZoomin                     |  false   |                                                `PropTypes.bool`                                                 | Making the webview scrollable on iOS when zoomed in even if scrollEnabled is false.                                                                        |
65
+| scrollEnabledWithZoomedin                     |  false   |                                                `PropTypes.bool`                                                 | Making the webview scrollable on iOS when zoomed in even if scrollEnabled is false.                                                                        |
66
 | zoomable                     |  true   |                                                `PropTypes.bool`                                                 | Only works on iOS when disable scalesPageToFit, in other conditions, using custom scripts to create viewport meta to disable zooming.                                                                        |
66
 | zoomable                     |  true   |                                                `PropTypes.bool`                                                 | Only works on iOS when disable scalesPageToFit, in other conditions, using custom scripts to create viewport meta to disable zooming.                                                                        |
67
 | showsVerticalScrollIndicator |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview).                                                                                                                                                      |
67
 | showsVerticalScrollIndicator |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview).                                                                                                                                                      |
68
 | showsVerticalScrollIndicator |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview).                                                                                                                                                      |
68
 | showsVerticalScrollIndicator |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview).                                                                                                                                                      |

+ 4
- 4
autoHeightWebView/index.js View File

12
 
12
 
13
 const AutoHeightWebView = React.memo(
13
 const AutoHeightWebView = React.memo(
14
   forwardRef((props, ref) => {
14
   forwardRef((props, ref) => {
15
-    const { style, onMessage, onSizeUpdated, scrollableWhenZoomin, scrollEnabled, source } = props;
15
+    const { style, onMessage, onSizeUpdated, scrollEnabledWithZoomedin, scrollEnabled, source } = props;
16
 
16
 
17
     if (!source) {
17
     if (!source) {
18
       return null;
18
       return null;
46
         return;
46
         return;
47
       }
47
       }
48
       const { height, width, zoomin } = data;
48
       const { height, width, zoomin } = data;
49
-      !scrollEnabled && scrollableWhenZoomin && setScrollable(zoomin);
49
+      !scrollEnabled && scrollEnabledWithZoomedin && setScrollable(zoomin);
50
       const { height: previousHeight, width: previousWidth } = size;
50
       const { height: previousHeight, width: previousWidth } = size;
51
       isSizeChanged({ height, previousHeight, width, previousWidth }) &&
51
       isSizeChanged({ height, previousHeight, width, previousWidth }) &&
52
         setSize({
52
         setSize({
55
         });
55
         });
56
     };
56
     };
57
 
57
 
58
-    const currentScrollEnabled = scrollEnabled === false && scrollableWhenZoomin ? scrollable : scrollEnabled;
58
+    const currentScrollEnabled = scrollEnabled === false && scrollEnabledWithZoomedin ? scrollable : scrollEnabled;
59
 
59
 
60
     const { currentSource, script } = reduceData(props);
60
     const { currentSource, script } = reduceData(props);
61
 
61
 
105
   customScript: PropTypes.string,
105
   customScript: PropTypes.string,
106
   customStyle: PropTypes.string,
106
   customStyle: PropTypes.string,
107
   zoomable: PropTypes.bool,
107
   zoomable: PropTypes.bool,
108
-  scrollableWhenZoomin: PropTypes.bool,
108
+  scrollEnabledWithZoomedin: PropTypes.bool,
109
   // webview props
109
   // webview props
110
   originWhitelist: PropTypes.arrayOf(PropTypes.string),
110
   originWhitelist: PropTypes.arrayOf(PropTypes.string),
111
   onMessage: PropTypes.func,
111
   onMessage: PropTypes.func,

+ 4
- 4
autoHeightWebView/utils.js View File

91
   });
91
   });
92
 `
92
 `
93
 
93
 
94
-const getBaseScript = ({ style, zoomable, scalesPageToFit, scrollableWhenZoomin }) =>
94
+const getBaseScript = ({ style, zoomable, scalesPageToFit, scrollEnabledWithZoomedin }) =>
95
   `
95
   `
96
   ;
96
   ;
97
   if (!document.getElementById("rnahw-wrapper")) {
97
   if (!document.getElementById("rnahw-wrapper")) {
107
   window.addEventListener('resize', updateSize);
107
   window.addEventListener('resize', updateSize);
108
   ${domMutationObserveScript}
108
   ${domMutationObserveScript}
109
   ${makeScalePageToFit(zoomable, scalesPageToFit)}
109
   ${makeScalePageToFit(zoomable, scalesPageToFit)}
110
-  ${scrollableWhenZoomin ? detectZoomChanged : ''}
110
+  ${scrollEnabledWithZoomedin ? detectZoomChanged : ''}
111
   updateSize();
111
   updateSize();
112
   `;
112
   `;
113
 
113
 
155
   </script>
155
   </script>
156
 `;
156
 `;
157
 
157
 
158
-const getScript = ({ files, customStyle, customScript, style, zoomable, scalesPageToFit, scrollableWhenZoomin }) => {
159
-  let script = getBaseScript({ style, zoomable, scalesPageToFit, scrollableWhenZoomin });
158
+const getScript = ({ files, customStyle, customScript, style, zoomable, scalesPageToFit, scrollEnabledWithZoomedin }) => {
159
+  let script = getBaseScript({ style, zoomable, scalesPageToFit, scrollEnabledWithZoomedin });
160
   script = files && files.length > 0 ? appendFilesToHead({ files, script }) : script;
160
   script = files && files.length > 0 ? appendFilesToHead({ files, script }) : script;
161
   script = appendStylesToHead({ style: customStyle, script });
161
   script = appendStylesToHead({ style: customStyle, script });
162
   customScript && (script = customScript + script);
162
   customScript && (script = customScript + script);

+ 1
- 1
demo/App.js View File

115
         alignItems: 'center',
115
         alignItems: 'center',
116
       }}>
116
       }}>
117
       <AutoHeightWebView
117
       <AutoHeightWebView
118
-        scrollableWhenZoomin
118
+        scrollEnabledWithZoomedin
119
         scrollEnabled={false}
119
         scrollEnabled={false}
120
         customStyle={
120
         customStyle={
121
           `
121
           `

+ 1
- 1
index.d.ts View File

26
   customScript: string;
26
   customScript: string;
27
   customStyle: string;
27
   customStyle: string;
28
   zoomable: boolean;
28
   zoomable: boolean;
29
-  scrollableWhenZoomin: boolean;
29
+  scrollEnabledWithZoomedin: boolean;
30
 }
30
 }
31
 
31
 
32
 export default class AutoHeightWebView extends Component<Partial<AutoHeightWebViewProps>> {}
32
 export default class AutoHeightWebView extends Component<Partial<AutoHeightWebViewProps>> {}