# BridgeScrollView **Repository Path**: yscodingman/bridge-scroll-view ## Basic Information - **Project Name**: BridgeScrollView - **Description**: SwiftUI,ScrollView获取contentOffset,contentSize,滑动状态,滑动方向,以及分页滑动等功能 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2024-08-05 - **Last Updated**: 2024-08-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BridgeScrollView #### 功能介绍 1. 当前偏移量 2. ScrollView的contentSize 3. 当前滚动状态(包括静止和滚动中以及滚动方向) 4. 当前是否是人为拖动 5. 是否处于惯性滚动中 6. 当前是否处于顶部 7. 当前是否处于底部 8. 当前是否正在缩放 9. 当前的缩放比例 10. 设置是否分页滑动 11. 设置是否需要回弹效果 12. 滚动到指定位置(设置contentOffset或使用SwiftUI滚动代理滚动到指定ID) #### 使用说明 1. 添加配置 ``` @ObservedObject var configuration = BridgeScrollConfiguration() ``` 2. 绑定配置 ``` ScrollView { // do some thing } .scrollViewOffsetObserver(configuration) } ``` 3. 获取当前ScrollView状态(onReceive和onChanged根据需要自由选择) ``` ScrollView { // do some thing } .scrollViewOffsetObserver(configuration) .onReceive(configuration.$contentOffset) { value in print("contentOffset", value) } .onReceive(configuration.$contentSize) { value in print("contentSize", value) } .onReceive(configuration.$isScrolling) { value in print("isScrolling", value) } .onReceive(configuration.$isDecelerating) { value in print("isDecelerating", value) } .onReceive(configuration.$isDragging) { value in print("isDragging", value) } .onReceive(configuration.$isTop) { value in print("isTop", value) } .onReceive(configuration.$isBottom) { value in print("isBottom", value) } .onReceive(configuration.$isZooming) { value in print("isZooming", value) } .onReceive(configuration.$zoomLevel) { value in print("zoomLevel", value) } .onReceive(configuration.$isUserScroll) { value in print("isUserScroll", value) } .onReceive(configuration.$scrollType) { value in print("scrollType", value) } ``` 4. 滑动到指定位置 ``` // 设置Offset configuration.configuration.scrollToOffset?(yourOffsetPoint, true) // 通过ID configuration.scrollViewProxy?.scrollTo(yourID, anchor: .bottom) ``` #### 安装(SPM) 使用Swift Package Manager安装 ``` https://gitee.com/yscodingman/bridge-scroll-view.git ```