javascript - Google+ Style Image Gallery -
i'm trying emmulate following:
any ideas how? photos have same height , photos arrange/cropped/resized dynamically fit on rows there no jagged sides left or right. if resize browser window resizes photos fit. have tried isotope , jquery masonry , neither give me effect.
i implemented thing. here's how did it:
- when page loads, measure available width of target container (the container images live), , call maxwidth
- i make ajax call, passing maxwidth server
- i determine list of gallery images display on server, , process each 1 one
- during iteration of list, keep adding images row, row's length being maxwidth available (which passed up). once image overflows maxwidth, calculate overflow amount
- i take overflow amount, divide number of images in row, , subtract value off each of images in row (so 1 image doesn't width reduced much)
- i repeat each row, each row adds maxwidth
some things had consider:
- i had take account width of margins wanted in between each image, , factor maxwidth accumulated value when processing each row.
- we needed corner stamp image (an image larger , fixed in top left corner. image encompassed 2 rows, , wider other thumbnails. had calculate different maxwidth first 2 rows consequence.
- i had recalculate dimensions when browser resized. binding resize event of window caused multiple ajax calls during dragging. had fix resize event fired when done.
overall, image gallery turned out quite well. he's screenshot.
Comments
Post a Comment