From 35d07366fb93749994a15b1128b81b12d879a8bb Mon Sep 17 00:00:00 2001 From: Yevhenii Date: Wed, 11 Nov 2026 15:40:17 +0200 Subject: [PATCH 1/2] Implement fadingEdgeLength for ScrollView on iOS ScrollView declares fadingEdgeLength on its cross-platform props, but only Android implements it: the iOS view config does not list it and iOS's props have no field for it, so iOS drops the value. RCTScrollViewComponentView masks the inner UIScrollView's layer with a CAGradientLayer in which each edge fades over its own length at full strength, which is what Android draws for {start, end}. The iOS view config forwards fadingEdgeLength and horizontal, so the mask follows the declared axis. The prop moves to BaseScrollViewProps, where both platforms parse it, and to the shared props in Flow, the TypeScript types and the API snapshot. horizontal now resets to false when the prop is removed, as its declared default is. It reset to true, so a ScrollView whose horizontal prop was removed kept its horizontal axis on iOS. --- .../Components/ScrollView/ScrollView.js | 28 ++-- .../ScrollView/ScrollViewNativeComponent.js | 2 + .../ScrollView/RCTScrollViewComponentView.mm | 88 +++++++++++ .../RCTScrollViewComponentViewTests.mm | 139 ++++++++++++++++++ .../scrollview/BaseScrollViewProps.cpp | 9 +- .../scrollview/BaseScrollViewProps.h | 2 + .../HostPlatformScrollViewProps.cpp | 15 +- .../scrollview/HostPlatformScrollViewProps.h | 1 - packages/react-native/ReactNativeApi.d.ts | 44 +++--- .../Components/ScrollView/ScrollView.d.ts | 30 ++-- .../Libraries/Lists/FlatList.d.ts | 2 - .../js/examples/FlatList/FlatList-basic.js | 27 ++-- .../examples/ScrollView/ScrollViewExample.js | 71 +++++++-- .../ReactAndroidFrameworksCxx.api | 2 +- .../api-snapshots/ReactAppleFrameworksCxx.api | 1 + .../ReactCommonFrameworksCxx.api | 1 + 16 files changed, 366 insertions(+), 96 deletions(-) diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index cc34b8046952..fcf39e89e625 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -442,21 +442,6 @@ export type ScrollViewPropsAndroid = Readonly<{ * @platform android */ persistentScrollbar?: ?boolean, - /** - * Controls the fading effect at the edges of the scroll content. - * - * A value greater than 0 will apply the fading effect, indicating more content is available - * to scroll. - * - * You can specify a single number to apply the same fading length to both edges. - * Alternatively, use an object with `start` and `end` properties to set different - * fading lengths for the start and end of the scroll content. - * - * The default value is 0. - * - * @platform android - */ - fadingEdgeLength?: ?number | {start: number, end: number}, /** * When false, the ScrollView will not automatically scroll to a focused child when * the child requests focus. This can be useful when you want to control the scroll @@ -525,6 +510,19 @@ type ScrollViewBaseProps = Readonly<{ * @default `'normal'` */ decelerationRate?: ?DecelerationRateType, + /** + * Controls the fading effect at the edges of the scroll content. + * + * A value greater than 0 will apply the fading effect, indicating more content is available + * to scroll. + * + * You can specify a single number to apply the same fading length to both edges. + * Alternatively, use an object with `start` and `end` properties to set different + * fading lengths for the start and end of the scroll content. + * + * The default value is 0. + */ + fadingEdgeLength?: ?number | {start: number, end: number}, /** * *Experimental, iOS Only*. The API is experimental and will change in future releases. diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js index eeee1a603e72..c2808ad30088 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js @@ -124,6 +124,8 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = endDraggingSensitivityMultiplier: true, directionalLockEnabled: true, disableIntervalMomentum: true, + fadingEdgeLength: true, + horizontal: true, indicatorStyle: true, inverted: true, keyboardDismissMode: true, diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 8efc837a8d61..7b98004fd6bd 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -57,6 +57,22 @@ static UIScrollViewIndicatorStyle RCTUIScrollViewIndicatorStyleFromProps(const S } } +static CGFloat RCTFadingEdgeLengthFromValue(const folly::dynamic *value) +{ + return (value != nullptr && value->isNumber()) ? fmax(value->asDouble(), 0) : 0; +} + +static void RCTGetFadingEdgeLengths(const ScrollViewProps &props, CGFloat *start, CGFloat *end) +{ + const auto &fadingEdgeLength = props.fadingEdgeLength; + if (fadingEdgeLength.isObject()) { + *start = RCTFadingEdgeLengthFromValue(fadingEdgeLength.get_ptr("start")); + *end = RCTFadingEdgeLengthFromValue(fadingEdgeLength.get_ptr("end")); + } else { + *start = *end = RCTFadingEdgeLengthFromValue(&fadingEdgeLength); + } +} + // Once Fabric implements proper NativeAnimationDriver, this should be removed. // This is just a workaround to allow animations based on onScroll event. // This is only used to animate sticky headers in ScrollViews, and only the contentOffset and tag is used. @@ -124,6 +140,8 @@ @implementation RCTScrollViewComponentView { BOOL _avoidAdjustmentForMaintainVisibleContentPosition; RCTVirtualViewContainerState *_virtualViewContainerState; + + CAGradientLayer *_fadingEdgeMaskLayer; } + (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view @@ -316,6 +334,7 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics _containerView.transform = transform; _scrollView.transform = transform; } + [self _updateFadingEdgeMask]; } - (bool)isInverted @@ -460,10 +479,77 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & scrollView.keyboardDismissMode = RCTUIKeyboardDismissModeFromProps(newScrollViewProps); } + BOOL fadingEdgeChanged = oldScrollViewProps.fadingEdgeLength != newScrollViewProps.fadingEdgeLength || + oldScrollViewProps.horizontal != newScrollViewProps.horizontal; + [super updateProps:props oldProps:oldProps]; // Must run after `super updateProps:` so it is based on the latest calculated view. ((RCTEnhancedScrollView *)_scrollView).inverted = [self isInverted]; + + if (fadingEdgeChanged) { + [self _updateFadingEdgeMask]; + } +} + +// Android's `View.draw` geometry: each edge fades over its own length, scaled so that neither passes the middle. +- (void)_updateFadingEdgeMask +{ + const auto &props = static_cast(*_props); + CGFloat start; + CGFloat end; + RCTGetFadingEdgeLengths(props, &start, &end); + CGFloat length = fmax(start, end); + CGFloat extent = props.horizontal ? _scrollView.bounds.size.width : _scrollView.bounds.size.height; + + if (length == 0 || extent == 0) { + // A mask costs an offscreen pass, so a scroll view without a fading edge carries none. + if (_fadingEdgeMaskLayer != nil) { + _scrollView.layer.mask = nil; + _fadingEdgeMaskLayer = nil; + } + return; + } + + CGFloat fadeLength = fmin(length, extent / 2); + if (_fadingEdgeMaskLayer == nil) { + _fadingEdgeMaskLayer = [CAGradientLayer layer]; + _fadingEdgeMaskLayer.colors = @[ + (id)UIColor.clearColor.CGColor, + (id)UIColor.blackColor.CGColor, + (id)UIColor.blackColor.CGColor, + (id)UIColor.clearColor.CGColor, + ]; + } + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + // `start` and `end` are logical edges: in RTL the scroll view is mirrored, and its mask with it. + _fadingEdgeMaskLayer.startPoint = props.horizontal ? CGPointMake(0, 0.5) : CGPointMake(0.5, 0); + _fadingEdgeMaskLayer.endPoint = props.horizontal ? CGPointMake(1, 0.5) : CGPointMake(0.5, 1); + _fadingEdgeMaskLayer.locations = @[ + @0, + @(fadeLength * start / length / extent), + @(1 - fadeLength * end / length / extent), + @1, + ]; + _fadingEdgeMaskLayer.frame = _scrollView.bounds; + [CATransaction commit]; + + // The scroll view rather than this view: RCTViewComponentView owns `currentContainerView.layer.mask`. + _scrollView.layer.mask = _fadingEdgeMaskLayer; +} + +- (void)_layoutFadingEdgeMask +{ + if (_fadingEdgeMaskLayer == nil) { + return; + } + // The mask is laid out in the scroll view's bounds, whose origin is the content offset. + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + _fadingEdgeMaskLayer.frame = _scrollView.bounds; + [CATransaction commit]; } - (void)updateState:(const State::Shared &)state oldState:(const State::Shared &)oldState @@ -759,6 +845,8 @@ - (BOOL)touchesShouldCancelInContentView:(__unused UIView *)view - (void)scrollViewDidScroll:(UIScrollView *)scrollView { + [self _layoutFadingEdgeMask]; + auto scrollMetrics = [self _scrollViewMetrics]; [self _updateStateWithContentOffset]; diff --git a/packages/react-native/React/Tests/Mounting/RCTScrollViewComponentViewTests.mm b/packages/react-native/React/Tests/Mounting/RCTScrollViewComponentViewTests.mm index 82b350755668..d7652b7123ad 100644 --- a/packages/react-native/React/Tests/Mounting/RCTScrollViewComponentViewTests.mm +++ b/packages/react-native/React/Tests/Mounting/RCTScrollViewComponentViewTests.mm @@ -9,8 +9,19 @@ #import #import #import +#import +#import +#import +#import +#import +using facebook::react::ContextContainer; +using facebook::react::EmptyLayoutMetrics; +using facebook::react::LayoutMetrics; using facebook::react::Props; +using facebook::react::PropsParserContext; +using facebook::react::RawProps; +using facebook::react::RawPropsParser; using facebook::react::ScrollViewProps; using facebook::react::ScrollViewShadowNode; @@ -23,6 +34,25 @@ return props; } +static Props::Shared makeFadingEdgeProps(folly::dynamic fadingEdgeLength, bool horizontal = false) +{ + auto props = std::make_shared(); + props->fadingEdgeLength = std::move(fadingEdgeLength); + props->horizontal = horizontal; + return props; +} + +static Props::Shared parseScrollViewProps(const folly::dynamic &rawValue, const ScrollViewProps &sourceProps) +{ + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + auto rawProps = RawProps(rawValue); + auto parser = RawPropsParser(); + parser.prepare(); + rawProps.parse(parser); + return std::make_shared(parserContext, sourceProps, rawProps); +} + @interface RCTScrollViewComponentView (Tests) - (void)_keyboardWillChangeFrame:(NSNotification *)notification; @end @@ -61,6 +91,115 @@ - (void)testAutomaticallyAdjustKeyboardInsetsAcrossRecycling XCTAssertEqual(view.scrollView.contentInset.bottom, 50); } +- (CAGradientLayer *)fadingEdgeMaskOf:(RCTScrollViewComponentView *)view +{ + CALayer *mask = view.scrollView.layer.mask; + XCTAssertTrue([mask isKindOfClass:[CAGradientLayer class]]); + return (CAGradientLayer *)mask; +} + +- (void)assertLocations:(NSArray *)locations equal:(NSArray *)expected +{ + XCTAssertEqual(locations.count, expected.count); + for (NSUInteger index = 0; index < MIN(locations.count, expected.count); index++) { + XCTAssertEqualWithAccuracy(locations[index].doubleValue, expected[index].doubleValue, 1e-6); + } +} + +- (void)testFadingEdgeLengthFadesEachEdgeOverItsOwnLength +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(folly::dynamic::object("start", 20)("end", 40)) + oldProps:ScrollViewShadowNode::defaultSharedProps()]; + + CAGradientLayer *mask = [self fadingEdgeMaskOf:view]; + XCTAssertTrue(CGPointEqualToPoint(mask.startPoint, CGPointMake(0.5, 0))); + XCTAssertTrue(CGPointEqualToPoint(mask.endPoint, CGPointMake(0.5, 1))); + [self assertLocations:mask.locations equal:@[ @0, @0.1, @0.8, @1 ]]; + XCTAssertTrue(CGRectEqualToRect(mask.frame, view.scrollView.bounds)); +} + +- (void)testFadingEdgeLengthNumberFadesBothEdges +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(30) oldProps:ScrollViewShadowNode::defaultSharedProps()]; + + [self assertLocations:[self fadingEdgeMaskOf:view].locations equal:@[ @0, @0.15, @0.85, @1 ]]; +} + +- (void)testHorizontalFadingEdgeLengthFadesAlongTheWidth +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(folly::dynamic::object("start", 20)("end", 0), true) + oldProps:ScrollViewShadowNode::defaultSharedProps()]; + + CAGradientLayer *mask = [self fadingEdgeMaskOf:view]; + XCTAssertTrue(CGPointEqualToPoint(mask.startPoint, CGPointMake(0, 0.5))); + XCTAssertTrue(CGPointEqualToPoint(mask.endPoint, CGPointMake(1, 0.5))); + [self assertLocations:mask.locations equal:@[ @0, @0.2, @1, @1 ]]; +} + +- (void)testParsedFadingEdgeFollowsTheAxisWhenHorizontalIsRemoved +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + auto horizontalProps = + parseScrollViewProps(folly::dynamic::object("fadingEdgeLength", 20)("horizontal", true), ScrollViewProps{}); + [view updateProps:horizontalProps oldProps:ScrollViewShadowNode::defaultSharedProps()]; + XCTAssertTrue(CGPointEqualToPoint([self fadingEdgeMaskOf:view].startPoint, CGPointMake(0, 0.5))); + + auto verticalProps = parseScrollViewProps( + folly::dynamic::object("horizontal", nullptr), static_cast(*horizontalProps)); + [view updateProps:verticalProps oldProps:horizontalProps]; + + CAGradientLayer *mask = [self fadingEdgeMaskOf:view]; + XCTAssertTrue(CGPointEqualToPoint(mask.startPoint, CGPointMake(0.5, 0))); + XCTAssertTrue(CGPointEqualToPoint(mask.endPoint, CGPointMake(0.5, 1))); + [self assertLocations:mask.locations equal:@[ @0, @0.1, @0.9, @1 ]]; +} + +- (void)testFadingEdgesNeverOverlap +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(folly::dynamic::object("start", 300)("end", 150)) + oldProps:ScrollViewShadowNode::defaultSharedProps()]; + + [self assertLocations:[self fadingEdgeMaskOf:view].locations equal:@[ @0, @0.5, @0.75, @1 ]]; +} + +- (void)testZeroFadingEdgeLengthRemovesTheMask +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(40) oldProps:ScrollViewShadowNode::defaultSharedProps()]; + XCTAssertNotNil(view.scrollView.layer.mask); + + [view updateProps:makeFadingEdgeProps(0) oldProps:nullptr]; + XCTAssertNil(view.scrollView.layer.mask); +} + +- (void)testFadingEdgeMaskFollowsTheContentOffset +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(40) oldProps:ScrollViewShadowNode::defaultSharedProps()]; + + view.scrollView.contentSize = CGSizeMake(100, 1000); + view.scrollView.contentOffset = CGPointMake(0, 300); + + XCTAssertTrue(CGRectEqualToRect([self fadingEdgeMaskOf:view].frame, CGRectMake(0, 300, 100, 200))); +} + +- (void)testFadingEdgeMaskFollowsTheScrollViewSize +{ + RCTScrollViewComponentView *view = [[RCTScrollViewComponentView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)]; + [view updateProps:makeFadingEdgeProps(40) oldProps:ScrollViewShadowNode::defaultSharedProps()]; + [self assertLocations:[self fadingEdgeMaskOf:view].locations equal:@[ @0, @0.2, @0.8, @1 ]]; + + LayoutMetrics layoutMetrics = EmptyLayoutMetrics; + layoutMetrics.frame.size = {100, 400}; + [view updateLayoutMetrics:layoutMetrics oldLayoutMetrics:EmptyLayoutMetrics]; + + [self assertLocations:[self fadingEdgeMaskOf:view].locations equal:@[ @0, @0.1, @0.9, @1 ]]; +} + @end #endif diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp index 9e3c351e32e6..92dca27acb68 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp @@ -170,13 +170,19 @@ BaseScrollViewProps::BaseScrollViewProps( rawProps, "horizontal", sourceProps.horizontal, - true)), + false)), padsContentForSafeArea(convertRawProp( context, rawProps, "padsContentForSafeArea", sourceProps.padsContentForSafeArea, false)), + fadingEdgeLength(convertRawProp( + context, + rawProps, + "fadingEdgeLength", + sourceProps.fadingEdgeLength, + nullptr)), scrollEventThrottle(convertRawProp( context, rawProps, @@ -301,6 +307,7 @@ void BaseScrollViewProps::setProp( RAW_SET_PROP_SWITCH_CASE_BASIC(persistentScrollbar); RAW_SET_PROP_SWITCH_CASE_BASIC(horizontal); RAW_SET_PROP_SWITCH_CASE_BASIC(padsContentForSafeArea); + RAW_SET_PROP_SWITCH_CASE_BASIC(fadingEdgeLength); RAW_SET_PROP_SWITCH_CASE_BASIC(scrollEventThrottle); RAW_SET_PROP_SWITCH_CASE_BASIC(zoomScale); RAW_SET_PROP_SWITCH_CASE_BASIC(contentInset); diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h index c6c3138ecbdf..8ef7c6e703b4 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -64,6 +65,7 @@ class BaseScrollViewProps : public ViewProps { bool persistentScrollbar{false}; bool horizontal{false}; bool padsContentForSafeArea{false}; + folly::dynamic fadingEdgeLength{}; Float scrollEventThrottle{}; Float zoomScale{1.0f}; EdgeInsets contentInset{}; diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp index 2aa02d73854c..246cb8f93c03 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp @@ -32,12 +32,6 @@ HostPlatformScrollViewProps::HostPlatformScrollViewProps( "nestedScrollEnabled", sourceProps.nestedScrollEnabled, false)), - fadingEdgeLength(convertRawProp( - context, - rawProps, - "fadingEdgeLength", - sourceProps.fadingEdgeLength, - nullptr)), overScrollMode(convertRawProp( context, rawProps, @@ -72,7 +66,6 @@ void HostPlatformScrollViewProps::setProp( switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(sendMomentumEvents); RAW_SET_PROP_SWITCH_CASE_BASIC(nestedScrollEnabled); - RAW_SET_PROP_SWITCH_CASE_BASIC(fadingEdgeLength); RAW_SET_PROP_SWITCH_CASE_BASIC(overScrollMode); RAW_SET_PROP_SWITCH_CASE_BASIC(endFillColor); RAW_SET_PROP_SWITCH_CASE_BASIC(scrollsChildToFocus); @@ -287,6 +280,10 @@ folly::dynamic HostPlatformScrollViewProps::getDiffProps( result["horizontal"] = horizontal; } + if (fadingEdgeLength != oldProps->fadingEdgeLength) { + result["fadingEdgeLength"] = fadingEdgeLength; + } + if (scrollEventThrottle != oldProps->scrollEventThrottle) { result["scrollEventThrottle"] = scrollEventThrottle; } @@ -371,10 +368,6 @@ folly::dynamic HostPlatformScrollViewProps::getDiffProps( result["nestedScrollEnabled"] = nestedScrollEnabled; } - if (fadingEdgeLength != oldProps->fadingEdgeLength) { - result["fadingEdgeLength"] = fadingEdgeLength; - } - if (overScrollMode != oldProps->overScrollMode) { result["overScrollMode"] = overScrollMode; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h index 49fcc1cb7f7f..861af896df0c 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h @@ -35,7 +35,6 @@ class HostPlatformScrollViewProps : public BaseScrollViewProps { bool sendMomentumEvents{}; bool nestedScrollEnabled{}; - folly::dynamic fadingEdgeLength{}; std::string overScrollMode{"auto"}; SharedColor endFillColor{clearColor()}; bool scrollsChildToFocus{true}; diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index b352f656de23..b80c3e9f7893 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<57f47f589dc7eb46102f17c4570f55c3>> + * @generated SignedSource<<91524a0647e88986251b1132a50a14ea>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -4355,6 +4355,12 @@ declare type ScrollViewBaseProps = { readonly contentOffset?: PointProp readonly decelerationRate?: DecelerationRateType readonly disableIntervalMomentum?: boolean + readonly fadingEdgeLength?: + | (number | undefined) + | { + end: number + start: number + } readonly horizontal?: boolean readonly innerViewRef?: React.Ref readonly invertStickyHeaders?: boolean @@ -4434,12 +4440,6 @@ declare interface ScrollViewProps extends Readonly< > {} declare type ScrollViewPropsAndroid = { readonly endFillColor?: ColorValue - readonly fadingEdgeLength?: - | (number | undefined) - | { - end: number - start: number - } readonly nestedScrollEnabled?: boolean readonly overScrollMode?: "always" | "auto" | "never" readonly persistentScrollbar?: boolean @@ -5865,11 +5865,11 @@ export { AlertOptions, // 8a116d2a AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // eabf9148 - AnimatedFlatList, // 7dd37b2f + Animated, // 2088ae6d + AnimatedFlatList, // e72a7f4d AnimatedImage, // 70a521de - AnimatedScrollView, // 6e7d4228 - AnimatedSectionList, // ae393fe9 + AnimatedScrollView, // 156d82ee + AnimatedSectionList, // 9beeff7a AnimatedText, // 55bc68a2 AnimatedView, // ed267c3c AppConfig, // 80afc5fa @@ -5922,9 +5922,9 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // 93582d36 - FlatListInstance, // 44658d70 - FlatListProps, // 9bd2f266 + FlatList, // c6b9a109 + FlatListInstance, // 76e0ee2b + FlatListProps, // e805d225 FocusEvent, // eaa2af9d FontVariant, // 7c7558bb GestureResponderEvent, // 8a8611e2 @@ -6067,18 +6067,18 @@ export { ScrollEvent, // 5b300f75 ScrollResponderType, // d454c555 ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // ded391d4 + ScrollView, // 7e39cea8 ScrollViewImperativeMethods, // bbff2b8c ScrollViewInstance, // a59c167a - ScrollViewProps, // 0f5f149e - ScrollViewPropsAndroid, // 02f3df2e + ScrollViewProps, // bce0590d + ScrollViewPropsAndroid, // e691594a ScrollViewPropsIOS, // b2cf82e0 ScrollViewScrollToOptions, // 3313411e SectionBase, // 9f13db00 - SectionList, // 0c0b716d + SectionList, // 4f553d31 SectionListData, // 1a4de01a - SectionListInstance, // 2ce6ff23 - SectionListProps, // 270e3f29 + SectionListInstance, // e1813ca0 + SectionListProps, // 702d41a9 SectionListRenderItem, // 715b2086 SectionListRenderItemInfo, // 4a48a922 Separators, // 6a45f7e3 @@ -6153,10 +6153,10 @@ export { VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e VirtualizedListInstance, // 423ee7c0 - VirtualizedListProps, // 7eb90be3 + VirtualizedListProps, // 9709e6eb VirtualizedSectionList, // 9fd9cd61 VirtualizedSectionListInstance, // 12b706d5 - VirtualizedSectionListProps, // 645dfd17 + VirtualizedSectionListProps, // e5cd5679 WrapperComponentProvider, // 6ce47ba4 codegenNativeCommands, // 322f3f4e codegenNativeComponent, // c9cccb03 diff --git a/packages/react-native/types_DEPRECATED/Libraries/Components/ScrollView/ScrollView.d.ts b/packages/react-native/types_DEPRECATED/Libraries/Components/ScrollView/ScrollView.d.ts index d57d50b425e3..54f1636a9a7b 100644 --- a/packages/react-native/types_DEPRECATED/Libraries/Components/ScrollView/ScrollView.d.ts +++ b/packages/react-native/types_DEPRECATED/Libraries/Components/ScrollView/ScrollView.d.ts @@ -560,22 +560,6 @@ export interface ScrollViewPropsAndroid { */ nestedScrollEnabled?: boolean | undefined; - /** - * Controls the fading effect at the edges of the scroll content. - * - * A value greater than 0 will apply the fading effect, indicating more content is available - * to scroll. - * - * You can specify a single number to apply the same fading length to both edges. - * Alternatively, use an object with `start` and `end` properties to set different - * fading lengths for the start and end of the scroll content. - * - * The default value is 0. - * - * @platform android - */ - fadingEdgeLength?: number | {start: number; end: number} | undefined; - /** * Causes the scrollbars not to turn transparent when they are not in use. The default value is false. */ @@ -635,6 +619,20 @@ export interface ScrollViewProps */ decelerationRate?: 'fast' | 'normal' | number | undefined; + /** + * Controls the fading effect at the edges of the scroll content. + * + * A value greater than 0 will apply the fading effect, indicating more content is available + * to scroll. + * + * You can specify a single number to apply the same fading length to both edges. + * Alternatively, use an object with `start` and `end` properties to set different + * fading lengths for the start and end of the scroll content. + * + * The default value is 0. + */ + fadingEdgeLength?: number | {start: number; end: number} | undefined; + /** * When true the scroll view's children are arranged horizontally in a row * instead of vertically in a column. The default value is false. diff --git a/packages/react-native/types_DEPRECATED/Libraries/Lists/FlatList.d.ts b/packages/react-native/types_DEPRECATED/Libraries/Lists/FlatList.d.ts index 0914329f7833..a6e75f49eb37 100644 --- a/packages/react-native/types_DEPRECATED/Libraries/Lists/FlatList.d.ts +++ b/packages/react-native/types_DEPRECATED/Libraries/Lists/FlatList.d.ts @@ -157,8 +157,6 @@ export interface FlatListProps extends VirtualizedListProps { * fading lengths for the start and end of the scroll content. * * The default value is 0. - * - * @platform android */ fadingEdgeLength?: number | {start: number; end: number} | undefined; diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index d4cf6c7094ce..431c8a3bf762 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -36,7 +36,6 @@ import { Alert, Animated, I18nManager, - Platform, StyleSheet, TextInput, View, @@ -227,20 +226,18 @@ class FlatListExample extends React.PureComponent { this.state.maintainVisibleContentPosition, this._setBooleanValue('maintainVisibleContentPosition'), )} - {Platform.OS === 'android' && ( - - - this.setState({ - fadingEdgeLength: Number(event.nativeEvent.text), - }) - } - /> - - )} + + + this.setState({ + fadingEdgeLength: Number(event.nativeEvent.text), + }) + } + /> + diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js index 5e68863e1764..363fda59a47f 100644 --- a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js +++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js @@ -529,6 +529,15 @@ const examples: Array = [ return ; }, }, + { + name: 'fadingEdgeLength', + title: ' fadingEdgeLength\n', + description: + 'Fades the content out at the edges of the scroll view, with one length for both edges or one per edge.', + render(): React.Node { + return ; + }, + }, ]; if (Platform.OS === 'ios') { @@ -592,10 +601,10 @@ if (Platform.OS === 'ios') { }); } else if (Platform.OS === 'android') { examples.push({ - title: ' EndFillColor & FadingEdgeLength\n', - description: 'Toggle to set endFillColor and fadingEdgeLength.', + title: ' EndFillColor\n', + description: 'Toggle to set endFillColor.', render(): React.Node { - return ; + return ; }, }); examples.push({ @@ -851,15 +860,13 @@ const HorizontalScrollView = (props: { ); }; -const EndFillColorFadingEdgeLen = () => { +const EndFillColorExample = () => { const [endFillColor, setEndFillColor] = useState(''); - const [fadingEdgeLen, setFadingEdgeLen] = useState(0); return ( {ITEMS.map(createItemRow)} @@ -869,16 +876,42 @@ const EndFillColorFadingEdgeLen = () => { endFillColor === '' ? setEndFillColor('#A9DFD0') : setEndFillColor('') } /> -