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

Fetch selected image first on open #8

Open
404-html opened this issue Apr 4, 2022 · 4 comments
Open

Fetch selected image first on open #8

404-html opened this issue Apr 4, 2022 · 4 comments

Comments

@404-html
Copy link

404-html commented Apr 4, 2022

When running a gallery the images are fetched on a random order (probably dependent on the network).

fetching-images

It would be nice to start with fetching first image, then second, and so on.

@Goowwy
Copy link

Goowwy commented May 28, 2022

also think so.
in header or footer component have currentindex, but dont know how to get in gallery

@LukasMod
Copy link

LukasMod commented Jun 1, 2022

@Goowwy
For initialState I used prop initialIndex. But I have all images fetched before gallery opens, I just pass right index from my image array and it works

@Goowwy
Copy link

Goowwy commented Jun 21, 2022

may you copy code?

@LukasMod
Copy link

LukasMod commented Jun 22, 2022

@Goowwy I render list of images and add onPress to that list items, which sets initial index and shows gallery (boolean flag):

   const onPressImage = (id: string) => {
        setImageIndex(images.findIndex(image => image.fileId === id))
        showGallery()
    }
 <Gallery
    close={hideGallery}
    isOpen={isGallery}
    images={images}
    initialIndex={initialIndex}
    renderHeaderComponent={renderHeader}
 />

Hope it helps

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

No branches or pull requests

3 participants