ソースを参照

feat(WKWebview): [ios] Add 'pagingEnabled' property to the iOS WKWebview (#165)

wiscat 5 年 前
コミット
4870e1f06a
共有7 個のファイルを変更した34 個の追加3 個の削除を含む
  1. 11
    0
      docs/Reference.md
  2. 1
    0
      ios/RNCWKWebView.h
  3. 4
    3
      ios/RNCWKWebView.m
  4. 1
    0
      ios/RNCWKWebViewManager.m
  5. 1
    0
      js/WebView.ios.js
  6. 8
    0
      js/WebViewTypes.js
  7. 8
    0
      typings/index.d.ts

+ 11
- 0
docs/Reference.md ファイルの表示

46
 - [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures)
46
 - [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures)
47
 - [`allowFileAccess`](Reference.md#allowFileAccess)
47
 - [`allowFileAccess`](Reference.md#allowFileAccess)
48
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
48
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
49
+- [`pagingEnabled`](Reference.md#pagingEnabled)
49
 
50
 
50
 ## Methods Index
51
 ## Methods Index
51
 
52
 
517
 | ------- | -------- | -------- |
518
 | ------- | -------- | -------- |
518
 | boolean | No       | Android  |
519
 | boolean | No       | Android  |
519
 
520
 
521
+---
522
+
523
+### `pagingEnabled`
524
+
525
+If the value of this property is true, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is false.
526
+
527
+| Type    | Required | Platform |
528
+| ------- | -------- | -------- |
529
+| boolean | No       | iOS      |
530
+
520
 ## Methods
531
 ## Methods
521
 
532
 
522
 ### `extraNativeComponentConfig()`
533
 ### `extraNativeComponentConfig()`

+ 1
- 0
ios/RNCWKWebView.h ファイルの表示

26
 @property (nonatomic, assign) BOOL messagingEnabled;
26
 @property (nonatomic, assign) BOOL messagingEnabled;
27
 @property (nonatomic, copy) NSString *injectedJavaScript;
27
 @property (nonatomic, copy) NSString *injectedJavaScript;
28
 @property (nonatomic, assign) BOOL scrollEnabled;
28
 @property (nonatomic, assign) BOOL scrollEnabled;
29
+@property (nonatomic, assign) BOOL pagingEnabled;
29
 @property (nonatomic, assign) CGFloat decelerationRate;
30
 @property (nonatomic, assign) CGFloat decelerationRate;
30
 @property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
31
 @property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
31
 @property (nonatomic, assign) BOOL bounces;
32
 @property (nonatomic, assign) BOOL bounces;

+ 4
- 3
ios/RNCWKWebView.m ファイルの表示

70
     _automaticallyAdjustContentInsets = YES;
70
     _automaticallyAdjustContentInsets = YES;
71
     _contentInset = UIEdgeInsetsZero;
71
     _contentInset = UIEdgeInsetsZero;
72
   }
72
   }
73
-    
73
+
74
   // Workaround for a keyboard dismissal bug present in iOS 12
74
   // Workaround for a keyboard dismissal bug present in iOS 12
75
   // https://openradar.appspot.com/radar?id=5018321736957952
75
   // https://openradar.appspot.com/radar?id=5018321736957952
76
   if (@available(iOS 12.0, *)) {
76
   if (@available(iOS 12.0, *)) {
111
     _webView.UIDelegate = self;
111
     _webView.UIDelegate = self;
112
     _webView.navigationDelegate = self;
112
     _webView.navigationDelegate = self;
113
     _webView.scrollView.scrollEnabled = _scrollEnabled;
113
     _webView.scrollView.scrollEnabled = _scrollEnabled;
114
+    _webView.scrollView.pagingEnabled = _pagingEnabled;
114
     _webView.scrollView.bounces = _bounces;
115
     _webView.scrollView.bounces = _bounces;
115
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
116
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
116
     _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
117
     _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
137
         [_webView removeFromSuperview];
138
         [_webView removeFromSuperview];
138
         _webView = nil;
139
         _webView = nil;
139
     }
140
     }
140
-    
141
+
141
     [super removeFromSuperview];
142
     [super removeFromSuperview];
142
 }
143
 }
143
 
144
 
146
     keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
147
     keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
147
     [[NSRunLoop mainRunLoop] addTimer:keyboardTimer forMode:NSRunLoopCommonModes];
148
     [[NSRunLoop mainRunLoop] addTimer:keyboardTimer forMode:NSRunLoopCommonModes];
148
 }
149
 }
149
-  
150
+
150
 -(void)keyboardWillShow
151
 -(void)keyboardWillShow
151
 {
152
 {
152
     if (keyboardTimer != nil) {
153
     if (keyboardTimer != nil) {

+ 1
- 0
ios/RNCWKWebViewManager.m ファイルの表示

45
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
45
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
46
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
46
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
48
+RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
48
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
49
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
49
 
50
 
50
 /**
51
 /**

+ 1
- 0
js/WebView.ios.js ファイルの表示

269
         injectedJavaScript={this.props.injectedJavaScript}
269
         injectedJavaScript={this.props.injectedJavaScript}
270
         bounces={this.props.bounces}
270
         bounces={this.props.bounces}
271
         scrollEnabled={this.props.scrollEnabled}
271
         scrollEnabled={this.props.scrollEnabled}
272
+        pagingEnabled={this.props.pagingEnabled}
272
         decelerationRate={decelerationRate}
273
         decelerationRate={decelerationRate}
273
         contentInset={this.props.contentInset}
274
         contentInset={this.props.contentInset}
274
         automaticallyAdjustContentInsets={
275
         automaticallyAdjustContentInsets={

+ 8
- 0
js/WebViewTypes.js ファイルの表示

168
    */
168
    */
169
   scrollEnabled?: ?boolean,
169
   scrollEnabled?: ?boolean,
170
 
170
 
171
+  /**
172
+   * If the value of this property is true, the scroll view stops on multiples
173
+   * of the scroll view’s bounds when the user scrolls.
174
+   * The default value is false.
175
+   * @platform ios
176
+   */
177
+  pagingEnabled?: ?boolean,
178
+
171
   /**
179
   /**
172
    * The amount by which the web view content is inset from the edges of
180
    * The amount by which the web view content is inset from the edges of
173
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
181
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.

+ 8
- 0
typings/index.d.ts ファイルの表示

145
    */
145
    */
146
   scrollEnabled?: boolean;
146
   scrollEnabled?: boolean;
147
 
147
 
148
+  /**
149
+   * If the value of this property is true, the scroll view stops on multiples
150
+   * of the scroll view’s bounds when the user scrolls.
151
+   * The default value is false.
152
+   * @platform ios
153
+   */
154
+  pagingEnabled?: boolean,
155
+
148
   /**
156
   /**
149
    * The amount by which the web view content is inset from the edges of
157
    * The amount by which the web view content is inset from the edges of
150
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
158
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.