-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onTapGesture event is confused in nested ScrollView #2046
Comments
I played with this code and it prints out exactly "0, 1, 2" to me. So can it be a SwiftUI version or iOS system version issue? I tried on Xcode 14.3 with an iPhone 14 Pro simulator with iOS 16.4. Can you verify the behavior too? Or do you have any comments on the reproducible SDK/device versions? |
@onevcat These are the image URLs I used for testing: let imageURLs = [
"https://static.freebeatfit.com/course/image/2d3e0b78e2ae4bacb984c388ae66d54e.15",
"https://static.freebeatfit.com/course/image/9147882e1ab9460495f8e52edc9beaa5.03",
"https://static.freebeatfit.com/course/image/bfbebb6ff9214719885a561953db947f.jpeg"
] |
It is quite surprising! Let me check it later. |
OK, it is a notorious thing that related to the image size (difference between its visual size and its content size) I suggest you insert a KFImage(URL(string: imageURLs[index]))
.resizable()
.scaledToFill()
.frame(width: 300, height: 400)
.clipped()
+ .contentShape(Rectangle())
.onTapGesture {
print(index)
} |
Interesting. I thought it was only effective for Spacer(). |
The introduction of iOS 18 brought a new bug that made `KFAnimatedImage` not recognize tap gestures and become unclickable. (onevcat/Kingfisher#2295) This commit addresses the issue with a workaround found here: onevcat/Kingfisher#2046 (comment) The workaround was suggested by the author of the library to fix a slightly different issue, but that property seems to work for our purposes. The issue is addressed by adding a `contentShape` property to usages of `KFAnimatedImage`, in order to make them clickable. A custom modifier was created to make the solution less obscure and more obvious. Furthermore, one empty tap gesture handler was removed as it was preventing other tap gesture handlers on the image carousel from being triggered on iOS 18 Testing ------- PASS Configurations: - iPhone 13 mini on iOS 18.0 - iPhone SE simulator on iOS 17.5 Damus: This commit Coverage: - Check that the following views are clickable: - Images in the carousel - Profile picture on notes - Profile picture on thread comments - Profile picture on profile page Changelog-Fixed: Fix items that became unclickable on iOS 18 Closes: damus-io#2342 Closes: damus-io#2370 Signed-off-by: Daniel D’Aquino <[email protected]>
The introduction of iOS 18 brought a new bug that made `KFAnimatedImage` not recognize tap gestures and become unclickable. (onevcat/Kingfisher#2295) This commit addresses the issue with a workaround found here: onevcat/Kingfisher#2046 (comment) The workaround was suggested by the author of the library to fix a slightly different issue, but that property seems to work for our purposes. The issue is addressed by adding a `contentShape` property to usages of `KFAnimatedImage`, in order to make them clickable. A custom modifier was created to make the solution less obscure and more obvious. Furthermore, one empty tap gesture handler was removed as it was preventing other tap gesture handlers on the image carousel from being triggered on iOS 18 Testing ------- PASS Configurations: - iPhone 13 mini on iOS 18.0 - iPhone SE simulator on iOS 17.5 Damus: This commit Coverage: - Check that the following views are clickable: - Images in the carousel - Profile picture on notes - Profile picture on thread comments - Profile picture on profile page Changelog-Fixed: Fix items that became unclickable on iOS 18 Closes: damus-io#2342 Closes: damus-io#2370 Signed-off-by: Daniel D’Aquino <[email protected]>
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Issue Description
KFImage
onTapGesture event is confused in nestedScrollView
What
I used
KFImage
in the nestedScrollView
, and addonTapGesture
event to printing index for everyKFImage
, and the wrong index will be printed.Reproduce
click
KFImage
in turn, printed 1, 1, 2.The text was updated successfully, but these errors were encountered: