10000 Fixes swipe to refresh triggers early when address bar is hidden (#901) · chmodawk/Android@ea3eef2 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea3eef2

Browse files
author
Usiel Riedl
authored
Fixes swipe to refresh triggers early when address bar is hidden (duckduckgo#901)
- Do not abort nestedScroll - Enable swipe to refresh only when no vertical nestedOffset is indicated Fixes duckduckgo#900
1 parent 7bf0ba1 commit ea3eef2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/src/main/java/com/duckduckgo/app/browser/DuckDuckGoWebView.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ class DuckDuckGoWebView : WebView, NestedScrollingChild {
9292

9393
returnValue = super.onTouchEvent(event)
9494

95-
if (scrollY == 0 && lastClampedTopY) {
96-
// we have reached the top and are clamped -> enable swipeRefresh (by default always disabled)
97-
enableSwipeRefresh(true)
98-
99-
stopNestedScroll()
100-
} else if (dispatchNestedScroll(0, scrollOffset[1], 0, deltaY, scrollOffset)) {
95+
if (dispatchNestedScroll(0, scrollOffset[1], 0, deltaY, scrollOffset)) {
10196
event.offsetLocation(0f, scrollOffset[1].toFloat())
10297
nestedOffsetY += scrollOffset[1]
10398
lastY -= scrollOffset[1]
10499
}
105100

101+
if (scrollY == 0 && lastClampedTopY && nestedOffsetY == 0) {
102+
// we have reached the top, are clamped vertically and nestedScrollY is done too -> enable swipeRefresh (by default always disabled)
103+
enableSwipeRefresh(true)
104+
}
105+
106106
lastDeltaY = deltaY
107107
}
108108

@@ -153,7 +153,7 @@ class DuckDuckGoWebView : WebView, NestedScrollingChild {
153153
override fun onOverScrolled(scrollX: Int, scrollY: Int, clampedX: Boolean, clampedY: Boolean) {
154154
// taking into account lastDeltaY since we are only interested whether we clamped at the top
155155
lastClampedTopY = clampedY && lastDeltaY <= 0
156-
enableSwipeRefresh(clampedY && scrollY == 0)
156+
enableSwipeRefresh(clampedY && scrollY == 0 && (lastDeltaY <= 0 || nestedOffsetY == 0))
157157
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY)
158158
}
159159

0 commit comments

Comments
 (0)
0