capacitor-swipe-gestures-plugin 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,46 +1,19 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
|
-
import WebKit
|
|
4
3
|
|
|
5
4
|
@objc(CapacitorSwipeGesturesPlugin)
|
|
6
5
|
public class CapacitorSwipeGesturesPlugin: CAPPlugin {
|
|
7
|
-
private var refreshControl: UIRefreshControl?
|
|
8
|
-
|
|
9
6
|
@objc func enable(_ call: CAPPluginCall) {
|
|
10
|
-
// Enable back/forward navigation gestures
|
|
11
7
|
webView?.allowsBackForwardNavigationGestures = true;
|
|
12
|
-
|
|
13
|
-
// Enable pull-to-refresh
|
|
14
|
-
if let wkWebView = webView as? WKWebView {
|
|
15
|
-
if refreshControl == nil {
|
|
16
|
-
refreshControl = UIRefreshControl()
|
|
17
|
-
refreshControl?.addTarget(self, action: #selector(refreshWebView(_:)), for: .valueChanged)
|
|
18
|
-
wkWebView.scrollView.addSubview(refreshControl!)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
8
|
call.resolve([
|
|
23
9
|
"status": "enable"
|
|
24
10
|
])
|
|
25
11
|
}
|
|
26
12
|
|
|
27
13
|
@objc func disable(_ call: CAPPluginCall) {
|
|
28
|
-
// Disable back/forward navigation gestures
|
|
29
14
|
webView?.allowsBackForwardNavigationGestures = false;
|
|
30
|
-
|
|
31
|
-
// Disable pull-to-refresh
|
|
32
|
-
if refreshControl != nil {
|
|
33
|
-
refreshControl?.removeFromSuperview()
|
|
34
|
-
refreshControl = nil
|
|
35
|
-
}
|
|
36
|
-
|
|
37
15
|
call.resolve([
|
|
38
16
|
"status": "disable"
|
|
39
17
|
])
|
|
40
18
|
}
|
|
41
|
-
|
|
42
|
-
@objc private func refreshWebView(_ sender: UIRefreshControl) {
|
|
43
|
-
webView?.reload()
|
|
44
|
-
sender.endRefreshing()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
19
|
+
}
|