Skip to content

Commit 7ab518d

Browse files
authored
Fix EPUB tap event sent twice when using a mouse (#275)
1 parent 54090f6 commit 7ab518d

File tree

12 files changed

+25
-3
lines changed

12 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file. Take a look
3030

3131
* Fixed a race condition issue with the `AVTTSEngine`, when pausing utterances.
3232
* Fixed crash with `PublicationSpeechSynthesizer`, when the currently played word cannot be resolved.
33+
* Fixed EPUB tap event sent twice when using a mouse (e.g. on Apple Silicon or with a mouse on an iPad).
3334

3435

3536
## [2.4.0]

Sources/Navigator/EPUB/EPUBSpreadView.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ class EPUBSpreadView: UIView, Loggable, PageView {
9393
addSubview(webView)
9494
setupWebView()
9595

96-
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapBackground)))
96+
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapBackground))
97+
gestureRecognizer.delegate = self
98+
addGestureRecognizer(gestureRecognizer)
9799

98100
for script in scripts {
99101
webView.configuration.userContentController.addUserScript(script)
@@ -514,6 +516,14 @@ extension EPUBSpreadView: WKUIDelegate {
514516
}
515517
}
516518

519+
extension EPUBSpreadView: UIGestureRecognizerDelegate {
520+
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
521+
// Prevents the tap event from being triggered by the fallback tap
522+
// gesture recognizer when it is also recognized by the web view.
523+
true
524+
}
525+
}
526+
517527
private extension EPUBSpreadView {
518528

519529
func updateActivityIndicator() {

TestApp/Integrations/Carthage/project+lcp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ targets:
3939
settings:
4040
LIBRARY_SEARCH_PATHS: $(PROJECT_DIR)/Carthage
4141
OTHER_SWIFT_FLAGS: -DLCP
42+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}
4243

TestApp/Integrations/Carthage/project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ targets:
3434
- package: MBProgressHUD
3535
settings:
3636
LIBRARY_SEARCH_PATHS: $(PROJECT_DIR)/Carthage
37+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}
3738

TestApp/Integrations/CocoaPods/project+lcp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ targets:
1010
- path: Sources
1111
settings:
1212
OTHER_SWIFT_FLAGS: $(inherited) -DLCP
13+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}

TestApp/Integrations/CocoaPods/project.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ targets:
88
deploymentTarget: "14.0"
99
sources:
1010
- path: Sources
11+
settings:
12+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}

TestApp/Integrations/Local/project+lcp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ targets:
4444
- package: SwiftSoup
4545
settings:
4646
OTHER_SWIFT_FLAGS: -DLCP
47+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}
4748

TestApp/Integrations/Local/project.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ targets:
3636
- package: Kingfisher
3737
- package: MBProgressHUD
3838
- package: SwiftSoup
39+
settings:
40+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}
3941

TestApp/Integrations/SPM/project+lcp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ targets:
4545
- package: SwiftSoup
4646
settings:
4747
OTHER_SWIFT_FLAGS: -DLCP
48+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}

TestApp/Integrations/SPM/project.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ targets:
3636
- package: GRDB
3737
- package: Kingfisher
3838
- package: MBProgressHUD
39+
settings:
40+
DEVELOPMENT_TEAM: ${RD_DEVELOPMENT_TEAM}
3941

0 commit comments

Comments
 (0)