diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 242b8ebba..88765a863 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -98,23 +98,37 @@ export default function Gallery() { return ( - {({ height, width }) => ( - - {({ index, style }) => - {getThumbnail(data, index * 5)} - {getThumbnail(data, index * 5 + 1)} - {getThumbnail(data, index * 5 + 2)} - {getThumbnail(data, index * 5 + 3)} - {getThumbnail(data, index * 5 + 4)} - } - - )} + {({ height, width }) => { + let columns; + if (width >= 1000) { + columns = 5; + } else if (width < 1000 && width >= 450) { + columns = 3; + } else if (width < 450 && width >= 300) { + columns = 2; + } else { + columns = 1; + } + return ( + + {({ index, style }) => { + const arr = []; + for (let i = 0; i < columns; i++) { + arr.push(index * columns + i); + } + return ( + {arr.map(i => getThumbnail(data, i))} + ); + }} + + ) + }}