From 37c6e25ac3743518d0775203144abbb2af4a8a5b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 7 May 2018 14:50:08 +0200 Subject: [PATCH] Finally got a proper scaling for carousel widget pictures --- .../http/static/css/widgets/image-carousel.css | 1 - .../http/static/js/widgets/image-carousel.js | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/platypush/backend/http/static/css/widgets/image-carousel.css b/platypush/backend/http/static/css/widgets/image-carousel.css index 31c6e89a9a..38bea13708 100644 --- a/platypush/backend/http/static/css/widgets/image-carousel.css +++ b/platypush/backend/http/static/css/widgets/image-carousel.css @@ -9,7 +9,6 @@ .carousel > img { flex-shrink: 0; - max-height: 100%; border-radius: 5px; height: 22.5em; } diff --git a/platypush/backend/http/static/js/widgets/image-carousel.js b/platypush/backend/http/static/js/widgets/image-carousel.js index 4b5a37916f..8726cc7243 100644 --- a/platypush/backend/http/static/js/widgets/image-carousel.js +++ b/platypush/backend/http/static/js/widgets/image-carousel.js @@ -15,17 +15,19 @@ $(document).ready(function() { var refreshImage = function() { var $oldImg = $imgContainer.find('img'); - var $newImg = $imgContainer.find('img').clone() - .attr('src', images[processedImages++]).css('min-width', '') - .hide().appendTo($imgContainer); - - if ($newImg.width() > $newImg.height()) { - $newImg.css('min-width', '100%'); - } + var $newImg = $('') + .attr('src', images[processedImages++]) + .attr('alt', 'Could not load image') + .appendTo('body').hide(); $newImg.on('load', function() { $oldImg.remove(); - $newImg.fadeIn(); + if ($newImg.width() > $newImg.height()) { + $newImg.css('width', '100%'); + } + + $newImg.css('max-height', '100%'); + $newImg.remove().appendTo($imgContainer).fadeIn(); }); if (processedImages == images.length-1) {