diff options
author | Olivier Paroz <github@oparoz.com> | 2015-09-26 22:00:47 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-09-26 22:00:47 +0300 |
commit | 5359aa0f3b6de5d00abfb77b82e0802e817b4e60 (patch) | |
tree | 7caa4d6d34e523ff5e19c446788e47df43fa4e7a /js/galleryalbum.js | |
parent | e6c6c47906f88956e89dd2dfa2525ec676020074 (diff) |
Set the order of images in the album representations
Fixes #382
[ci skip]
Diffstat (limited to 'js/galleryalbum.js')
-rw-r--r-- | js/galleryalbum.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/js/galleryalbum.js b/js/galleryalbum.js index 905e5a42..deaa8cb0 100644 --- a/js/galleryalbum.js +++ b/js/galleryalbum.js @@ -128,12 +128,12 @@ * @param {GalleryImage} image * @param {number} targetHeight Each row has a specific height * @param {number} calcWidth Album width - * @param {object} a + * @param {jQuery} imageHolder * * @returns {$.Deferred<Thumbnail>} * @private */ - _getOneImage: function (image, targetHeight, calcWidth, a) { + _getOneImage: function (image, targetHeight, calcWidth, imageHolder) { // img is a Thumbnail.image, true means square thumbnails return image.getThumbnail(true).then(function (img) { if (image.thumbnail.valid) { @@ -146,11 +146,9 @@ // Adjust the size because of the margins around pictures backgroundHeight -= 2; - var croppedDiv = $('<div class="cropped">'); - croppedDiv.css("background-image", "url('" + img.src + "')"); - croppedDiv.css("height", backgroundHeight); - croppedDiv.css("width", backgroundWidth); - a.append(croppedDiv); + imageHolder.css("background-image", "url('" + img.src + "')"); + imageHolder.css("height", backgroundHeight); + imageHolder.css("width", backgroundWidth); } }); }, @@ -181,7 +179,11 @@ } targetWidth = targetWidth.toFixed(3); - thumbsArray.push(this._getOneImage(images[i], targetHeight, targetWidth, a)); + // Append the div first in order to not lose the order of images + var imageHolder = $('<div class="cropped">'); + a.append(imageHolder); + thumbsArray.push( + this._getOneImage(images[i], targetHeight, targetWidth, imageHolder)); } var labelWidth = (targetHeight - 0.01); |