We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I completely removed all scrolling / scroll-bouncing glitters by using Introspect:
Prev. issue: #40
// // BSScrollView.swift // // Created by Lucas Zischka. // Copyright © 2021-2022 Lucas Zischka. All rights reserved. // import UIKit import SwiftUI import Introspect class BSScrollViewDelegate: NSObject, UIScrollViewDelegate { func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { if scrollView.contentOffset.y == 0.0 { scrollView.bounces = false } else { scrollView.bounces = true } } func scrollViewDidScroll(_ scrollView: UIScrollView) { print(scrollView.contentOffset.y) if scrollView.contentOffset.y > 0.0 { scrollView.bounces = true } } } internal struct BSScrollView<Content: View>: View { @Binding private var isScrollEnabled: Bool private let scrollViewDelegate = BSScrollViewDelegate() private let defaultAxes: Axis.Set private let showsIndicators: Bool private let onChanged: (DragGestureView.Value) -> Void private let onEnded: (DragGestureView.Value) -> Void private let content: Content private var axes: Axis.Set { return self.isScrollEnabled ? self.defaultAxes : [] } var body: some View { ScrollView(self.axes, showsIndicators: self.showsIndicators) { self.content .dragGesture(onChanged: self.onChanged, onEnded: self.onEnded) } .introspectScrollView { scrollView in scrollView.delegate = scrollViewDelegate scrollView.bounces = false } } init(axes: Axis.Set = .vertical, showsIndicators: Bool = true, isScrollEnabled: Binding<Bool> = .constant(true), onChanged: @escaping (DragGestureView.Value) -> Void = { _ in}, onEnded: @escaping (DragGestureView.Value) -> Void = { _ in}, @ViewBuilder content: () -> Content) { self._isScrollEnabled = isScrollEnabled self.defaultAxes = axes self.showsIndicators = showsIndicators self.onChanged = onChanged self.onEnded = onEnded self.content = content() } } struct BSScrollView_Previews: PreviewProvider { static var previews: some View { BSScrollView { ForEach(0...100, id: \.self) { i in Text("\(i)") } } } }
The text was updated successfully, but these errors were encountered:
Thank you, I will test it soon.
Sorry, something went wrong.
No branches or pull requests
I completely removed all scrolling / scroll-bouncing glitters by using Introspect:
Prev. issue: #40
The text was updated successfully, but these errors were encountered: