Skip to content

Commit 9f806d8

Browse files
authored
Refactor, Fixes, and functionality to avoid processing nested scroll events on internal webview elements scrolls (#8)
* ANDROID-13326 NestedScrollWebView refactor, fixes for detected issues and improvements * ANDROID-13326 Extend implementation to cover both internal vertical and horizontal scrolls, also, update readme * ANDROID-13326 Remove uneeded param and fix CS * ANDROID-11326 Remove non-null assertion
1 parent c108524 commit 9f806d8

File tree

7 files changed

+880
-1020
lines changed

7 files changed

+880
-1020
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,17 @@ Just include directly the `NestedScrollWebView` in your layout:
8484

8585
## Configuration
8686

87+
Utility methods for specific WebView content requirements.
88+
89+
### Adjust WebView bottom margin to match CoordinatorLayout visible space
90+
8791
When expanding toolbar inside a CoordinatorLayout, instead of resizing the space left by the toolbar, it pushes down the content below.
8892

8993
This may be an issue for example for pages where a fixed footer element is displayed. So, in order to correctly resize the webview viewport on these expands you can add this attribute to the NestedScrollWebView.
9094

9195
`app:coordinatorBottomMatchingEnabled={"true"|"false"}`
9296

93-
This is disabled by default, as webview resizing is expensive.
97+
This is **disabled by default**, as webview resizing is expensive.
9498

9599
```xml
96100
<com.telefonica.nestedscrollwebview.NestedScrollWebView
@@ -101,13 +105,26 @@ This is disabled by default, as webview resizing is expensive.
101105
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
102106
```
103107

104-
## How we do it?
108+
### Block vertical nested scrolling on WebView internal elements scrolls
105109

106-
Implementation extends [WebView](https://developer.android.com/reference/android/webkit/WebView) applying nested scrolling code logic from androidx.core [NestedScrollView](https://developer.android.com/reference/androidx/core/widget/NestedScrollView).
110+
If your WebView content includes scrollable elements such as horizontal carousels or map views, nested scrolling should not be performed when scrolling these.
111+
112+
`app:blockNestedScrollingOnInternalContentScrolls={"true"|"false"}`
113+
114+
This is **enabled by default**, but can be disabled with this flag in case it does not work properly in any specific situation.
115+
116+
```xml
117+
<com.telefonica.nestedscrollwebview.NestedScrollWebView
118+
android:id="@+id/webView"
119+
android:layout_width="match_parent"
120+
android:layout_height="match_parent"
121+
app:blockNestedScrollingOnInternalContentScrolls="false"
122+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
123+
```
107124

108-
## Known issues, considerations and Future improvements
125+
## How we do it?
109126

110-
* As implementation relies on NestedScrollView touch events interception, in cases there are web content elements that intercept movement events, for example a map view or a horizontal carousel, these movement events will be interpreted also as scrolling events for nested scrolling. We are thinking on a solution to prevent this.
127+
Implementation extends [WebView](https://developer.android.com/reference/android/webkit/WebView) applying nested scrolling code logic from androidx.core [NestedScrollView](https://developer.android.com/reference/androidx/core/widget/NestedScrollView).
111128

112129
## Videos
113130
<table>

0 commit comments

Comments
 (0)