Skip to content

Commit

Permalink
feat: support border-radius on cursor (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming authored Oct 12, 2024
1 parent 9bf17ef commit 5565421
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ android/keystores/debug.keystore
# generated by bob
lib/

.history/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/react-native-tab-page-view",
"version": "1.0.15",
"version": "1.0.16",
"description": "React Native Tab Page View",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion src/PageContentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class PageContentView extends Component<PageContentViewProps> {
},
],
{
useNativeDriver: true,
useNativeDriver: false,
}
);
private scrollView: RefObject<ContentFlatList> | null = React.createRef();
Expand Down
14 changes: 7 additions & 7 deletions src/PageHeaderCursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class PageHeaderCursor extends Component<PageHeaderCursorProps> {

private _findPercentCursorWidth = () => {
const { width } = this.props.cursorStyle as any;
if (typeof width == 'string') {
if (typeof width === 'string') {
return width.match(/(\d+(\.\d+)?)%/)?.[1];
}
return null;
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class PageHeaderCursor extends Component<PageHeaderCursorProps> {
const width = item.width - left - right;
return isWidth
? (width * Number(percentWidth ?? 100)) / 100
: item.x + width / 2.0 + left;
: item.x + left;
}
} else {
return 0;
Expand Down Expand Up @@ -113,11 +113,11 @@ export default class PageHeaderCursor extends Component<PageHeaderCursorProps> {
override render() {
const fixCursorWidth = this._findFixCursorWidth();
const translateX = this._reloadPageIndexValue(false);
const scaleX = this._reloadPageIndexValue(true);
const widthX = this._reloadPageIndexValue(true);

const containerStyle: Animated.WithAnimatedObject<any> = {
transform: [{ translateX }, fixCursorWidth ? { scale: 1 } : { scaleX }],
width: fixCursorWidth ?? 1,
transform: [{ translateX }],
width: fixCursorWidth ?? widthX,
position: 'absolute',
top: 0,
bottom: 0,
Expand All @@ -127,7 +127,7 @@ export default class PageHeaderCursor extends Component<PageHeaderCursorProps> {

const contentStyle = [
this.props.cursorStyle,
{ left: null, right: null, width: fixCursorWidth ?? 1 },
{ left: null, right: null, width: fixCursorWidth ?? widthX },
];

return (
Expand All @@ -149,7 +149,7 @@ export default class PageHeaderCursor extends Component<PageHeaderCursorProps> {
{this.props.renderCursor ? (
this.props.renderCursor()
) : (
<View style={contentStyle}></View>
<Animated.View style={contentStyle} />
)}
</Animated.View>
</View>
Expand Down
6 changes: 4 additions & 2 deletions src/PageHeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ interface PageHeaderViewProps extends ScrollViewProps {

export default class PageHeaderView extends Component<PageHeaderViewProps> {
private scrollPageIndex = this.props.initialScrollIndex ?? 0;
private scrollPageIndexValue = new Animated.Value(this.scrollPageIndex);
private scrollPageIndexValue = new Animated.Value(this.scrollPageIndex, {
useNativeDriver: false,
});
private nextScrollPageIndex = -1;
private shouldHandlerAnimationValue = true;
private itemConfigList = this.props.data.map((_: any) => ({
Expand Down Expand Up @@ -217,7 +219,7 @@ export default class PageHeaderView extends Component<PageHeaderViewProps> {
this.scrollPageIndexValue,
index,
this.props.selectedPageIndexDuration,
true
false
);
}
this.props.onSelectedPageIndex?.(index);
Expand Down

0 comments on commit 5565421

Please sign in to comment.