Difference between revisions of "Team:Marburg/Gallery"
Line 381: | Line 381: | ||
var maxheight = 0; | var maxheight = 0; | ||
fades.each(function() { | fades.each(function() { | ||
− | + | maxwidth = ($(this).outerWidth() > maxwidth) ? $(this).outerWidth() : maxwidth; | |
− | + | maxheight = ($(this).outerHeight() > maxheight) ? $(this).outerHeight() : maxheight; | |
}); | }); | ||
this.height( maxheight ); | this.height( maxheight ); | ||
Line 400: | Line 400: | ||
} | } | ||
return this; | return this; | ||
+ | } | ||
+ | $.fn.rescaleGallery = function() { | ||
+ | //SCALE CONTAINER | ||
+ | $(this).ready(function() { | ||
+ | var parent = $('#fader'); | ||
+ | var fades = $('#fader img'); | ||
+ | var maxwidth = 0; | ||
+ | var maxheight = 0; | ||
+ | console.log("CALL on " + $(this).attr('alt') + " :" + fades.length); | ||
+ | fades.each(function() { | ||
+ | maxwidth = ($(this).outerWidth() > maxwidth) ? $(this).outerWidth() : maxwidth; | ||
+ | maxheight = ($(this).outerHeight() > maxheight) ? $(this).outerHeight() : maxheight; | ||
+ | }); | ||
+ | parent.height( maxheight ); | ||
+ | parent.width( maxwidth ); | ||
+ | //FIX IMAGE POSITIONS | ||
+ | fades.each(function() { | ||
+ | if( $(this).outerWidth() < maxwidth-2) | ||
+ | $(this).css('left',(maxwidth/2 - $(this).outerWidth()/2)); | ||
+ | if( $(this).outerHeight() < maxheight-2) | ||
+ | $(this).css('top',(maxheight/2 - $(this).outerHeight()/2)); | ||
+ | }); | ||
+ | }); | ||
} | } | ||
$.fn.setFader = function(interval,fadetime) { | $.fn.setFader = function(interval,fadetime) { | ||
Line 424: | Line 447: | ||
slideid = $('#fader').initGallery().setFader(3000,500); | slideid = $('#fader').initGallery().setFader(3000,500); | ||
$('#fader').hover(function() {clearInterval(slideid);},function() {slideid = $(this).setFader(3000,500);}); | $('#fader').hover(function() {clearInterval(slideid);},function() {slideid = $(this).setFader(3000,500);}); | ||
− | $('#fader img'). | + | $('#fader img').rescaleGallery(); |
}); | }); | ||
</script> | </script> |
Revision as of 15:20, 16 September 2015