I have a banner area with a defined height and I want the images that rotate within it to vertically center (height can be greater than the parent banner container with the overflow hidden). The images maintain full width of the browser until they reach 1750px wide and stop scaling down when they reach the height of the banner area. I have a script that vertically centers the variable height images on page load and when the browser window scales, but when I use this together with jQuery Cycle to rotate through the images, the scripts do not play nice. Everything seems ok initially, but if you resize the browser during the rotation the image shifts down so that the top of the image is at the halfway point of the banner area. If I remove the centering script the images don't shift but stay anchored at the top. If I remove the Cycle script the images don't shift but they also don't rotate (obviously)....so the problem is definitely with the two working together.
The site is at this address:
www.envisiondemo.com/planview(still a work in progress)
The vertical centering script looks like this:
var imageHeight, overlap, container = $('.banner');
function centerImage() {
imageHeight = container.find('img').height();
overlap = (520 - imageHeight) / 2;
container.find('img').css('margin-top', overlap);
}
$(window).on("load resize", centerImage);
Does anyone know how I might be able to make this script work with Cycle or is there a responsive rotator plugin/script that can vertically center the images within a fixed height parent container?
Please help! :-) Thanks!
-Steph M