Skip to content

Commit d3f3bfa

Browse files
kpsrokafacebook-github-bot
authored andcommitted
Added persistentScrollbar prop in ScrollView component (#22300)
Summary: This PR is a follow-up from the closed [discussions-and-proposals PR](react-native-community/discussions-and-proposals#39), that explains in more detail the rationale for adding this feature. Pull Request resolved: #22300 Reviewed By: fkgozali Differential Revision: D13121748 Pulled By: mdvacca fbshipit-source-id: 899641be79bdb41fa6649df0772c602a5e09b3b9
1 parent 0c8db08 commit d3f3bfa

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

Libraries/Components/ScrollView/ScrollView.js

+8
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ type AndroidProps = $ReadOnly<{|
301301
* @platform android
302302
*/
303303
overScrollMode?: ?('auto' | 'always' | 'never'),
304+
/**
305+
* Causes the scrollbars not to turn transparent when they are not in use.
306+
* The default value is false.
307+
*
308+
* @platform android
309+
*/
310+
persistentScrollbar?: ?boolean,
304311
|}>;
305312

306313
type VRProps = $ReadOnly<{|
@@ -442,6 +449,7 @@ export type Props = $ReadOnly<{|
442449
* Note: Vertical pagination is not supported on Android.
443450
*/
444451
pagingEnabled?: ?boolean,
452+
445453
/**
446454
* When false, the view cannot be scrolled via touch interaction.
447455
* The default value is true.

Libraries/Lists/VirtualizedList.js

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ type OptionalProps = {
175175
viewableItems: Array<ViewToken>,
176176
changed: Array<ViewToken>,
177177
}) => void,
178+
persistentScrollbar?: ?boolean,
178179
/**
179180
* Set this when offset is needed for the loading indicator to show correctly.
180181
* @platform android

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java

+5
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,9 @@ public void setBorderColor(ReactHorizontalScrollView view, int index, Integer co
255255
public void setOverflow(ReactHorizontalScrollView view, @Nullable String overflow) {
256256
view.setOverflow(overflow);
257257
}
258+
259+
@ReactProp(name = "persistentScrollbar")
260+
public void setPersistentScrollbar(ReactHorizontalScrollView view, boolean value) {
261+
view.setScrollbarFadingEnabled(!value);
262+
}
258263
}

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java

+5
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ public void scrollToEnd(
264264
}
265265
}
266266

267+
@ReactProp(name = "persistentScrollbar")
268+
public void setPersistentScrollbar(ReactScrollView view, boolean value) {
269+
view.setScrollbarFadingEnabled(!value);
270+
}
271+
267272
@Override
268273
public @Nullable Map<String, Object> getExportedCustomDirectEventTypeConstants() {
269274
return createExportedCustomDirectEventTypeConstants();

0 commit comments

Comments
 (0)