Skip to content

Commit

Permalink
feat(ios): Allow to configure WebView's ScrollView's content insets (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jan 30, 2020
1 parent 284d4b2 commit 1f7e40d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ios/Capacitor/Capacitor/CAPBridgeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKScr

webView = WKWebView(frame: .zero, configuration: webViewConfiguration)
webView?.scrollView.bounces = false

webView?.scrollView.contentInsetAdjustmentBehavior = .never

let availableInsets = ["automatic", "scrollableAxes", "never", "always"]
if let contentInset = (capConfig.getValue("ios.contentInset") as? String),
let index = availableInsets.firstIndex(of: contentInset) {
webView?.scrollView.contentInsetAdjustmentBehavior = UIScrollView.ContentInsetAdjustmentBehavior.init(rawValue: index)!
} else {
webView?.scrollView.contentInsetAdjustmentBehavior = .never
}

webView?.uiDelegate = self
webView?.navigationDelegate = self
if let allowsLinkPreview = (capConfig.getValue("ios.allowsLinkPreview") as? Bool) {
Expand Down
5 changes: 5 additions & 0 deletions site/docs-md/basics/configuring-your-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ The current ones you might configure are:
"appendUserAgent": "string to append for iOS",
// Background color of Capacitor WebView for iOS only
"backgroundColor": "#ffffffff",
// Configure the WebView's UIScrollView's content inset behavior
// Default is never
// Possible values are "automatic", "scrollableAxes", "never" and "always"
// https://developer.apple.com/documentation/uikit/uiscrollview/contentinsetadjustmentbehavior
"contentInset": "always",
// Configure the Swift version to be used for Cordova plugins.
// Default is 4.0
"cordovaSwiftVersion": "3.0",
Expand Down

0 comments on commit 1f7e40d

Please sign in to comment.