summaryrefslogtreecommitdiff
path: root/plugins/cordova-plugin-ios-longpress-fix/src/ios
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/cordova-plugin-ios-longpress-fix/src/ios')
-rwxr-xr-xplugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h7
-rwxr-xr-xplugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m35
2 files changed, 42 insertions, 0 deletions
diff --git a/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h
new file mode 100755
index 00000000..132bb8ad
--- /dev/null
+++ b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h
@@ -0,0 +1,7 @@
+#import <Cordova/CDVPlugin.h>
+
+@interface LongPressFix : CDVPlugin
+
+@property (nonatomic,strong) UILongPressGestureRecognizer *lpgr;
+
+@end \ No newline at end of file
diff --git a/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m
new file mode 100755
index 00000000..9f3d8521
--- /dev/null
+++ b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m
@@ -0,0 +1,35 @@
+#import "LongPressFix.h"
+
+@implementation LongPressFix
+
+- (void)pluginInitialize {
+ self.lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)];
+ self.lpgr.minimumPressDuration = 0.45f;
+ self.lpgr.allowableMovement = 100.0f;
+
+ NSArray *views = self.webView.subviews;
+ if (views.count == 0) {
+ NSLog(@"No webview subviews found, not applying the longpress fix");
+ return;
+ }
+ for (int i=0; i<views.count; i++) {
+ UIView *webViewScrollView = views[i];
+ if ([webViewScrollView isKindOfClass:[UIScrollView class]]) {
+ NSArray *webViewScrollViewSubViews = webViewScrollView.subviews;
+ UIView *browser = webViewScrollViewSubViews[0];
+ [browser addGestureRecognizer:self.lpgr];
+ NSLog(@"Applied longpress fix");
+ break;
+ }
+ }
+}
+
+- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender {
+ if ([sender isEqual:self.lpgr]) {
+ if (sender.state == UIGestureRecognizerStateBegan) {
+ NSLog(@"Ignoring a longpress in order to suppress the magnifying glass (iOS9 quirk)");
+ }
+ }
+}
+
+@end \ No newline at end of file