Bluesky app fork with some witchin' additions 💫

Fix scroll gesture alignment (#6898)

authored by danabra.mov and committed by

GitHub 84f4afd3 cd811114

+11 -11
+11 -11
src/view/com/util/MainScrollProvider.tsx
··· 60 60 const snapToClosestState = useCallback( 61 61 (e: NativeScrollEvent) => { 62 62 'worklet' 63 + const offsetY = Math.max(0, e.contentOffset.y) 63 64 if (isNative) { 64 65 const startDragOffsetValue = startDragOffset.get() 65 66 if (startDragOffsetValue === null) { 66 67 return 67 68 } 68 - const didScrollDown = e.contentOffset.y > startDragOffsetValue 69 + const didScrollDown = offsetY > startDragOffsetValue 69 70 startDragOffset.set(null) 70 71 startMode.set(null) 71 - if (e.contentOffset.y < headerHeight.get()) { 72 + if (offsetY < headerHeight.get()) { 72 73 // If we're close to the top, show the shell. 73 74 setMode(false) 74 75 } else if (didScrollDown) { ··· 86 87 const onBeginDrag = useCallback( 87 88 (e: NativeScrollEvent) => { 88 89 'worklet' 90 + const offsetY = Math.max(0, e.contentOffset.y) 89 91 if (isNative) { 90 - startDragOffset.set(e.contentOffset.y) 92 + startDragOffset.set(offsetY) 91 93 startMode.set(headerMode.get()) 92 94 } 93 95 }, ··· 121 123 const onScroll = useCallback( 122 124 (e: NativeScrollEvent) => { 123 125 'worklet' 126 + const offsetY = Math.max(0, e.contentOffset.y) 124 127 if (isNative) { 125 128 const startDragOffsetValue = startDragOffset.get() 126 129 const startModeValue = startMode.get() 127 130 if (startDragOffsetValue === null || startModeValue === null) { 128 - if ( 129 - headerMode.get() !== 0 && 130 - e.contentOffset.y < headerHeight.get() 131 - ) { 131 + if (headerMode.get() !== 0 && offsetY < headerHeight.get()) { 132 132 // If we're close enough to the top, always show the shell. 133 133 // Even if we're not dragging. 134 134 setMode(false) ··· 138 138 139 139 // The "mode" value is always between 0 and 1. 140 140 // Figure out how much to move it based on the current dragged distance. 141 - const dy = e.contentOffset.y - startDragOffsetValue 141 + const dy = offsetY - startDragOffsetValue 142 142 const dProgress = interpolate( 143 143 dy, 144 144 [-headerHeight.get(), headerHeight.get()], ··· 157 157 } 158 158 // On the web, we don't try to follow the drag because we don't know when it ends. 159 159 // Instead, show/hide immediately based on whether we're scrolling up or down. 160 - const dy = e.contentOffset.y - (startDragOffset.get() ?? 0) 161 - startDragOffset.set(e.contentOffset.y) 160 + const dy = offsetY - (startDragOffset.get() ?? 0) 161 + startDragOffset.set(offsetY) 162 162 163 - if (dy < 0 || e.contentOffset.y < WEB_HIDE_SHELL_THRESHOLD) { 163 + if (dy < 0 || offsetY < WEB_HIDE_SHELL_THRESHOLD) { 164 164 setMode(false) 165 165 } else if (dy > 0) { 166 166 setMode(true)