Skip to content

Commit 0dac88a

Browse files
lidord-wixM-i-k-e-l
authored andcommitted
ScrollBar - fix scrolling inside Dialog on Android (#2695)
* use ScrollView and FlatList from gesture-handler * formatting
1 parent 0b8e33a commit 0dac88a

File tree

1 file changed

+45
-48
lines changed

1 file changed

+45
-48
lines changed

src/components/scrollBar/index.tsx

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,69 @@ import _ from 'lodash';
22
import React, {Component, useCallback} from 'react';
33
import {
44
Animated,
5-
ScrollView,
6-
FlatList,
75
FlatListProps,
86
ImageSourcePropType,
97
NativeSyntheticEvent,
108
NativeScrollEvent,
119
LayoutChangeEvent
1210
} from 'react-native';
11+
import {ScrollView, FlatList} from 'react-native-gesture-handler';
1312
import {Colors} from '../../style';
1413
import {Constants, asBaseComponent, forwardRef, ForwardRefInjectedProps} from '../../commons/new';
1514
import View from '../view';
1615
import Image from '../image';
1716

18-
1917
export interface ScrollBarProps extends FlatListProps<any> {
2018
/**
21-
* Whether to use a FlatList. NOTE: you must pass 'data' and 'renderItem' props as well
22-
*/
23-
useList?: boolean,
24-
/**
25-
* The element to use as a container, instead of a View
26-
*/
27-
containerView?: React.ComponentClass,
28-
/**
29-
* The props to pass the container
30-
*/
31-
containerProps?: object,
32-
/**
33-
* The component's height
34-
*/
35-
height?: number,
36-
/**
37-
* The gradient's height, defaults to the component's height
38-
*/
39-
gradientHeight?: number,
40-
/**
41-
* The gradient's width
42-
*/
43-
gradientWidth?: number,
44-
/**
45-
* The gradient's margins for the edge
46-
*/
47-
gradientMargins?: number,
48-
/**
49-
* The gradient's tint color
50-
*/
51-
gradientColor?: string,
52-
/**
53-
* The gradient's image, instead of the default image.
54-
* NOTE: pass an image for the right-hand side and it will be flipped to match the left-hand side
55-
*/
56-
gradientImage?: ImageSourcePropType,
57-
/**
58-
* The index to currently focus on
59-
*/
60-
focusIndex?: number
19+
* Whether to use a FlatList. NOTE: you must pass 'data' and 'renderItem' props as well
20+
*/
21+
useList?: boolean;
22+
/**
23+
* The element to use as a container, instead of a View
24+
*/
25+
containerView?: React.ComponentClass;
26+
/**
27+
* The props to pass the container
28+
*/
29+
containerProps?: object;
30+
/**
31+
* The component's height
32+
*/
33+
height?: number;
34+
/**
35+
* The gradient's height, defaults to the component's height
36+
*/
37+
gradientHeight?: number;
38+
/**
39+
* The gradient's width
40+
*/
41+
gradientWidth?: number;
42+
/**
43+
* The gradient's margins for the edge
44+
*/
45+
gradientMargins?: number;
46+
/**
47+
* The gradient's tint color
48+
*/
49+
gradientColor?: string;
50+
/**
51+
* The gradient's image, instead of the default image.
52+
* NOTE: pass an image for the right-hand side and it will be flipped to match the left-hand side
53+
*/
54+
gradientImage?: ImageSourcePropType;
55+
/**
56+
* The index to currently focus on
57+
*/
58+
focusIndex?: number;
6159
}
6260

6361
type Props = ScrollBarProps & ForwardRefInjectedProps;
6462

6563
type State = {
66-
gradientOpacity: Animated.Value,
67-
gradientOpacityLeft: Animated.Value
64+
gradientOpacity: Animated.Value;
65+
gradientOpacityLeft: Animated.Value;
6866
};
6967

70-
7168
const GRADIENT_WIDTH = 76;
7269
const defaultImage = () => require('./assets/gradientOverlay.png');
7370

@@ -267,7 +264,8 @@ class ScrollBar extends Component<Props, State> {
267264
const Item = ({children, index, onLayout}: any) => {
268265
const onItemLayout = useCallback(({nativeEvent: {layout}}: LayoutChangeEvent) => {
269266
onLayout({layout, index});
270-
}, [children]);
267+
},
268+
[children]);
271269

272270
return (
273271
<View flexG onLayout={onItemLayout}>
@@ -279,4 +277,3 @@ const Item = ({children, index, onLayout}: any) => {
279277
Item.displayName = 'IGNORE';
280278
ScrollBar.Item = Item;
281279
export default asBaseComponent<ScrollBarProps, typeof ScrollBar>(forwardRef(ScrollBar));
282-

0 commit comments

Comments
 (0)