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

Gallery is static #339

Open
c0ncentus opened this issue Apr 29, 2024 · 2 comments
Open

Gallery is static #339

c0ncentus opened this issue Apr 29, 2024 · 2 comments

Comments

@c0ncentus
Copy link

Expected behaviour

when change the size, image is resized

Actual behaviour

when change the size, nothing happens

Steps to reproduce behaviour

import { Gallery } from "react-grid-gallery";
import Lightbox from "react-image-lightbox";
import { Image as IImage } from "react-grid-gallery";
export function GalleryShow({ images }: { images: Partial<GalleryImageItem>[] }) {
  const [index, setIndex] = useState(-1);
  const [size, setSize] = useState(120);

  const currentImage = images[index];
  const nextIndex = (index + 1) % images.length;
  const nextImage = images[nextIndex] || currentImage;
  const prevIndex = (index + images.length - 1) % images.length;
  const prevImage = images[prevIndex] || currentImage;

  const handleClick = (index: number, item: CustomImage) => setIndex(index);
  const handleClose = () => setIndex(-1);
  const handleMovePrev = () => setIndex(prevIndex);
  const handleMoveNext = () => setIndex(nextIndex);
  let DATA = images.map(e => { return { ...e, width: size, height: size } })
  useEffect(() => {
    DATA = images.map(e => { return { ...e, width: size, height: size } })
    console.log(DATA)
  }, [size])

  return (
    <div>
      <input type="range" min={20} defaultValue={size} max={400} step={20} onChange={(e) => { setSize(parseInt(e.currentTarget.value, 10)) }} />
      <Gallery images={DATA as GalleryImageItem[]} onClick={handleClick} enableImageSelection={false} />
      {!!currentImage && (
        <Lightbox mainSrc={currentImage.original!} imageTitle={currentImage.caption} mainSrcThumbnail={currentImage.src} nextSrc={nextImage.original!} nextSrcThumbnail={nextImage.src!}
          prevSrc={prevImage.original!} prevSrcThumbnail={prevImage.src!} onCloseRequest={handleClose} onMovePrevRequest={handleMovePrev} onMoveNextRequest={handleMoveNext}
        />
      )}
    </div>
  );
}
``` link the css too
### Operating system
windows 11
### Browser and version
Mozilla - latest
### Hardware
@itoldya
Copy link
Collaborator

itoldya commented Apr 29, 2024

Hey @c0ncentus, I just published a new version [email protected]. Can you try again, please?

@c0ncentus
Copy link
Author

c0ncentus commented Apr 29, 2024

the same issue (my data is updated via console.log and I checked that). the ui seems static

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

2 participants