Skip to content

Commit

Permalink
fix: 🐛 avoid conflict btw drag and tap gesture in Carousel
Browse files Browse the repository at this point in the history
Cherrypick from main
  • Loading branch information
shengxu7 committed Dec 9, 2024
1 parent f9623ab commit 0e97b6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ struct CarouselTestView: View {
ScrollView(.vertical) {
Carousel(numberOfColumns: Int(self.numberOfColumns), spacing: self.spacing, alignment: self.alignment == 0 ? .top : (self.alignment == 1 ? .center : .bottom), isSnapping: self.isSnapping, isSameHeight: self.isSameHeight) {
ForEach(0 ..< CardTests.cardSamples.count, id: \.self) { i in
CardTests.cardSamples[i]
NavigationLink(destination: Text("Detail View")) {
CardTests.cardSamples[i]
}
}
}
.cardStyle(.card)
Expand Down
4 changes: 2 additions & 2 deletions Sources/FioriSwiftUICore/Views/Carousel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public struct Carousel<Content>: View where Content: View {
self.isSameHeight = isSameHeight
self.content = content
}

public var body: some View {
CarouselViewLayout {
HStack {
Expand All @@ -259,7 +259,7 @@ public struct Carousel<Content>: View where Content: View {
}
}
.contentShape(Rectangle())
.gesture(
.highPriorityGesture(
DragGesture()
.onChanged { value in
self.contentOffset.x = self.preContentOffset.x + (self.layoutDirection == .leftToRight ? -1 : 1) * value.translation.width
Expand Down

0 comments on commit 0e97b6e

Please sign in to comment.