danielsaidi / ScrollKit

ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
MIT License
668 stars 24 forks source link

Losing touch events after a stretch #8

Closed edbarbier closed 9 months ago

edbarbier commented 10 months ago

Hey, first of all, great library.

Context: I only imported the ScrollViewHeader code in my project.

I noticed a small glitch that I'm not sure how to go about fixing. After a stretch, touch events stop being recognized on the containing views until the scrollView is scrolled.

My View hierarchy:

ScrollView { 
   VStack { 
      ScrollViewHeader { 
          HeaderView()
                Subview.tapGesture { 
                     print("tapped") // Issue occurs here.
                 }  
      }
   }
}

Issue: The print statement is called without issues unless the ScollViewHeader is pulled and stretched. After a stretch, the touch events are no longer recognized until the scrollView is scrolled down again.

It could be my design but I thought I would check here if someone else had this issue.

Please let me know if you would like more information.

Cheers and thanks again for this library. Ed

danielsaidi commented 9 months ago

Hi @edbarbier

Oh, that sounds strange. Let me check.

danielsaidi commented 9 months ago

Hmmm, it works for me in the demo app.

I added this to both the demo header, the Spotify preview header and to different views within the headers and it all works for me.

.onTapGesture { print("Tapped") }

Here you can se it applied to the Spotify preview header:

https://github.com/danielsaidi/ScrollKit/assets/429927/d114a3ef-6232-4f0e-bb8a-b8be329d726a

Did you make it work?

edbarbier commented 9 months ago

Hi Daniel,

Thanks for replying.

I ended up adding the tap gesture inside a view that is contained by the ScrollViewHeader.

I'll double check your code and compare with my implementation.

Cheers, Ed

danielsaidi commented 9 months ago

Great to hear it worked out. 👍