Recyclerlistview: Portrait/Landscape rotation - resize issue

Created on 23 Oct 2017  路  6Comments  路  Source: Flipkart/recyclerlistview

When I rotate the device the cells are upgraded their size only when I scroll, and not on rotation. I've set the canChangeSize={true} props, the _layoutProvider is called once the device is rotated with the right new sizes, but the cell width is expanded or reduced only after some scrolling.

bug

Most helpful comment

@naqvitalha I am facing the same issue in new version. When the layout orientation is changed the list does not maintain scroll position and also it does not resize.

The issue is marked as fixed. How to use this feature?

All 6 comments

I just looked at the code, looks like it's a regression. Inside VirtualRenderer we now check if renderStackHasChanged or not. In this case it doesn't change so the refresh doesn't occur.

We'll try to fix it in the next release. For now you can manually refresh. Wrap recycler in a view to detect orientation change and when it is detected call _refreshViewability on ref of RecyclerListView. That will do it. Code:

 _onLayout = e => {
        let orientation = null;
        if (e.nativeEvent.layout.width > e.nativeEvent.layout.height) {
            orientation = "L";
        } else {
            orientation = "P";
        }
        if (this.orientation != orientation) {
            this.orientation = orientation;
            if (this.recyclerRef) {
                //Making sure all compute is done before using setTimeout
                setTimeout(() => this.recyclerRef._refreshViewability(), 0);
            }
        }
    };

    render() {
        return (
            <View style={{ flex: 1, alignItems: "stretch" }} onLayout={this._onLayout}>
                <RecyclerListView ref={x => this.recyclerRef = x} canChangeSize={true} layoutProvider={this._layoutProvider} dataProvider={this.state.dataProvider} rowRenderer={this._rowRenderer} />
            </View>
        );
    }

Thank you very much with this fix it works! Thank you!

Great! Glad that it worked out. Anyways, the release after the next one will have this fix in core code itself. I'll close this once that is done.

Fixed in v1.2.0

@naqvitalha I am facing the same issue in new version. When the layout orientation is changed the list does not maintain scroll position and also it does not resize.

The issue is marked as fixed. How to use this feature?

Facing the same issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sksin28 picture sksin28  路  8Comments

witalobenicio picture witalobenicio  路  8Comments

H-Shafiei picture H-Shafiei  路  8Comments

ardyfeb picture ardyfeb  路  6Comments

h-asadollahi picture h-asadollahi  路  8Comments