1 year ago
#356745

danialzahid94
Only execute method if ScrollView is not being scrolled
I'm working with a view that contains a vertical ScrollView
an HStack
reflecting similar dates (they are both separate components though). When the vertical ScrollView
is scrolled, I am highlighting corresponding dates in the HStack
using onAppear
on the Text
elements in ScrollView
. This works because the elements are inside a LazyVStack
.
I also want to allow user to manually tap on an element in the HStack
which should trigger the scroll to that element. I'm using ScrollViewReader
to achieve this.
My problem is that this causes a cyclic block where a manual vertical scroll triggers highlighting in the HStack
which triggers a scroll again and user ends up with jittery scrolling.
To fix this I'm looking for a way to know if the ScrollView
is currently scrolling so I don't call the scrollTo
method when a different element gets highlight in the HStack
.
Keeping the scrollviewOffset
doesn't help because it wouldn't tell if the ScrollView
is still being scrolled at the moment.
ios
swiftui
hstack
0 Answers
Your Answer