Skip to content

Commit

Permalink
Fix missing on layout (#193)
Browse files Browse the repository at this point in the history
* Version bump

* Linking to updated props

* Fix missing onLayout

* 1.4.0-beta.6
  • Loading branch information
naqvitalha authored and muskeinsingh committed Jun 7, 2018
1 parent 598fbf6 commit 6cb14e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
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);
}
}
}

0 comments on commit 6cb14e5

Please sign in to comment.