capacitor-swipe-gestures-plugin 4.2.1 → 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,68 +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
- override public func load() {
10
- // Plugin initialization code if needed
11
- }
12
-
13
6
  @objc func enable(_ call: CAPPluginCall) {
14
- DispatchQueue.main.async {
15
- // Enable back/forward navigation gestures
16
- self.bridge?.webView?.allowsBackForwardNavigationGestures = true
17
-
18
- // Enable pull-to-refresh
19
- if let webView = self.bridge?.webView as? WKWebView {
20
- self.setupRefreshControl(webView)
21
- }
22
-
23
- call.resolve([
24
- "status": "enable"
25
- ])
26
- }
7
+ webView?.allowsBackForwardNavigationGestures = true;
8
+ call.resolve([
9
+ "status": "enable"
10
+ ])
27
11
  }
28
12
 
29
13
  @objc func disable(_ call: CAPPluginCall) {
30
- DispatchQueue.main.async {
31
- // Disable back/forward navigation gestures
32
- self.bridge?.webView?.allowsBackForwardNavigationGestures = false
33
-
34
- // Disable pull-to-refresh
35
- self.removeRefreshControl()
36
-
37
- call.resolve([
38
- "status": "disable"
39
- ])
40
- }
41
- }
42
-
43
- private func setupRefreshControl(_ webView: WKWebView) {
44
- // Remove existing refresh control if any
45
- removeRefreshControl()
46
-
47
- // Create new refresh control
48
- refreshControl = UIRefreshControl()
49
- refreshControl?.addTarget(self, action: #selector(self.refreshWebView(_:)), for: .valueChanged)
50
-
51
- // Add refresh control to webView's scrollView
52
- webView.scrollView.refreshControl = refreshControl
53
- }
54
-
55
- private func removeRefreshControl() {
56
- if let webView = self.bridge?.webView as? WKWebView {
57
- webView.scrollView.refreshControl = nil
58
- refreshControl = nil
59
- }
60
- }
61
-
62
- @objc private func refreshWebView(_ sender: UIRefreshControl) {
63
- if let webView = self.bridge?.webView {
64
- webView.reload()
65
- }
66
- sender.endRefreshing()
14
+ webView?.allowsBackForwardNavigationGestures = false;
15
+ call.resolve([
16
+ "status": "disable"
17
+ ])
67
18
  }
68
- }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-swipe-gestures-plugin",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "Capacitor swipe gestures plugin.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",