Skip to content

Commit

Permalink
Expose scrollable nodes (#690)
Browse files Browse the repository at this point in the history
* PLV now render after first onLayout

* ..

* scrollable node now a public API

Co-authored-by: Talha Naqvi <talha.naqvi@shopify.com>
  • Loading branch information
naqvitalha and naqvitalha authored Mar 8, 2022
1 parent 33bc8f5 commit 2ed1bee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
});
}

public getScrollableNode(): number | null {
if (this._scrollComponent && this._scrollComponent.getScrollableNode) {
return this._scrollComponent.getScrollableNode();
}
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 @@ -20,4 +20,9 @@ export interface ScrollComponentProps {
}
export default abstract class BaseScrollComponent extends React.Component<ScrollComponentProps, {}> {
public abstract scrollTo(x: number, y: number, animate: boolean): void;

//Override and return node handle to your custom scrollview. Useful if you need to use Animated Events.
public getScrollableNode(): number | null {
return null;
}
}
7 changes: 7 additions & 0 deletions src/platform/reactnative/scrollcomponent/ScrollComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export default class ScrollComponent extends BaseScrollComponent {
}
}

public getScrollableNode(): number | null {
if (this._scrollViewRef && this._scrollViewRef.getScrollableNode) {
return this._scrollViewRef.getScrollableNode();
}
return null;
}

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

0 comments on commit 2ed1bee

Please sign in to comment.