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

Fix missing on layout #193

Merged
merged 5 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recyclerlistview",
"version": "1.4.0-beta.5",
"version": "1.4.0-beta.6",
"description": "The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.",
"main": "dist/reactnative/index.js",
"types": "dist/reactnative/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/core/scrollcomponent/BaseScrollComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ScrollComponentProps {
scrollThrottle?: number;
distanceFromWindow?: number;
useWindowScroll?: boolean;
onLayout?: any;
}
export default abstract class BaseScrollComponent extends React.Component<ScrollComponentProps, {}> {
public abstract scrollTo(x: number, y: number, animate: boolean): void;
Expand Down
20 changes: 11 additions & 9 deletions src/platform/reactnative/scrollcomponent/ScrollComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default class ScrollComponent extends BaseScrollComponent {
private _height: number;
private _width: number;
private _isSizeChangedCalledOnce: boolean;
private _dummyOnLayout: (event: LayoutChangeEvent) => void = TSCast.cast(null);
private _scrollViewRef: ScrollView | null = null;

constructor(args: ScrollComponentProps) {
Expand All @@ -42,7 +41,7 @@ export default class ScrollComponent extends BaseScrollComponent {

public scrollTo(x: number, y: number, isAnimated: boolean): void {
if (this._scrollViewRef) {
this._scrollViewRef.scrollTo({x, y, animated: isAnimated});
this._scrollViewRef.scrollTo({ x, y, animated: isAnimated });
}
}

Expand All @@ -63,13 +62,13 @@ export default class ScrollComponent extends BaseScrollComponent {
// } = this.props;
return (
<Scroller ref={(scrollView: any) => this._scrollViewRef = scrollView as (ScrollView | null)}
removeClippedSubviews={false}
scrollEventThrottle={this.props.scrollThrottle}
{...this.props}
horizontal={this.props.isHorizontal}
onScroll={this._onScroll}
onLayout={(!this._isSizeChangedCalledOnce || this.props.canChangeSize) ? this._onLayout : this._dummyOnLayout}>
<View style={{flexDirection: this.props.isHorizontal ? "row" : "column"}}>
removeClippedSubviews={false}
scrollEventThrottle={this.props.scrollThrottle}
{...this.props}
horizontal={this.props.isHorizontal}
onScroll={this._onScroll}
onLayout={(!this._isSizeChangedCalledOnce || this.props.canChangeSize) ? this._onLayout : this.props.onLayout}>
<View style={{ flexDirection: this.props.isHorizontal ? "row" : "column" }}>
<View style={{
height: this.props.contentHeight,
width: this.props.contentWidth,
Expand Down Expand Up @@ -97,5 +96,8 @@ export default class ScrollComponent extends BaseScrollComponent {
this.props.onSizeChanged(event.nativeEvent.layout);
}
}
if (this.props.onLayout) {
this.props.onLayout(event);
}
}
}