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

initialRenderIndex broke rendering elements when height is enough to show all of them #178

Closed
maxfarseer opened this issue May 16, 2018 · 11 comments
Labels

Comments

@maxfarseer
Copy link

maxfarseer commented May 16, 2018

How to reproduce:

  1. Generate small list of elements (here in repo 3 items)
  2. Open the browser window with enough heigh to display all items
  3. Set up any initialRenderIndex different than 0 (1,2)

Expected results:

All items displayed.

Actual results:

No one element rendered

Screenshots

https://monosnap.com/file/rLQjgBXDla3I67yYVIHNOWX0LCZAND - normal page, height not enough
https://monosnap.com/file/IooCvMWVxPyaHgm5ouTOSMadNYV1KP - blank page, when height is enough


Demo repo

Codesandbox

@naqvitalha
Copy link
Contributor

Can you provide a sample on codesandbox.io for me to check? That will help me look into this ASAP.

@maxfarseer
Copy link
Author

@naqvitalha issue updated with link to codesandbox.

@naqvitalha
Copy link
Contributor

Ah! Indeed it's bug :(
RLV expects a scroll event to trigger render in case of explicit offset. Which won't happen here.
Can you avoid giving an explicit index when items are few? I will try to fix this ASAP.

@naqvitalha naqvitalha added the bug label May 16, 2018
@maxfarseer
Copy link
Author

maxfarseer commented May 17, 2018

Can you avoid giving an explicit index when items are few?

yeah, it's on my project already. Thx in advance!

@yuvaraj119
Copy link

yuvaraj119 commented May 23, 2018

@naqvitalha is this issue fixed any update.

@naqvitalha
Copy link
Contributor

It is fixed in 1.4.0-beta.4, it might be a while before it is available outside beta since master has big changes

@yuvaraj119
Copy link

Even in beta, the issue there. Now the data gets loaded faster on scrolling but the older issue is still there.
waiting for stable release.

@Jyrno42
Copy link

Jyrno42 commented May 31, 2018

I am currently using this as a workaround (both for initialRenderIndex and for scrollTo methods):

import { RecyclerListView as BaseRecyclerListView } from 'recyclerlistview';


class RecyclerListView extends BaseRecyclerListView {
    // Patch scrollToOffset so it does not overscroll
    /* eslint-disable */
    scrollToOffset(x, y, animate = false, pending = false) {
        if (this._scrollComponent) {
            const size = {
                height: 0,
                width: 0,

                ...this._initComplete ? this._virtualRenderer.getLayoutDimension() : {},
            };

            const visibleWidth = this._layout.width;
            const visibleHeight = this._layout.height;

            x = Math.min(x, size.width - visibleWidth);
            y = Math.min(y, size.height - visibleHeight);

            this._scrollComponent.scrollTo(x, y, animate);
        }
    }
    /* eslint-enable */
}

export default RecyclerListView;

@sbearben
Copy link

sbearben commented Jul 11, 2019

@naqvitalha -also running into this bug when I set an initialRenderIndex that is not 0 when I have a list that is small enough to render all items in the given space without the need to scroll - any updates on a potential fix?

@arunreddy10
Copy link
Collaborator

This bug has been fixed in the current release. Closing

@octavezero
Copy link

@arunreddy10 I am still able to reproduce this exact bug in v3.0.0. Is the fix included in this version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants