Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement getNativeScrollRef #776

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
return null;
}

public getNativeScrollRef(): unknown | null {
if (this._scrollComponent && this._scrollComponent.getNativeScrollRef) {
return this._scrollComponent.getNativeScrollRef();
}
return null;
}

public renderCompat(): JSX.Element {
//TODO:Talha
// const {
Expand Down
5 changes: 5 additions & 0 deletions src/core/scrollcomponent/BaseScrollComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ export default abstract class BaseScrollComponent extends React.Component<Scroll
public getScrollableNode(): number | null {
return null;
}

//Override and return ref to your custom scrollview. Useful if you need to use Animated Events on the new architecture.
public getNativeScrollRef(): unknown | null {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be unknown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really remember why I made it this way. Updated to match the type of FlatList.

return null;
}
}
4 changes: 4 additions & 0 deletions src/platform/reactnative/scrollcomponent/ScrollComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export default class ScrollComponent extends BaseScrollComponent {
return null;
}

public getNativeScrollRef(): unknown | null {
return this._scrollViewRef;
}

public render(): JSX.Element {
const Scroller = TSCast.cast<ScrollView>(this.props.externalScrollView); //TSI
const renderContentContainer = this.props.renderContentContainer ? this.props.renderContentContainer : this._defaultContainer;
Expand Down