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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/RecyclerListView.tsx
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
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
Contributor

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?

return null;
}
}
4 changes: 4 additions & 0 deletions src/platform/reactnative/scrollcomponent/ScrollComponent.tsx
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