PDA

View Full Version : jQuery in Safari: can't get div to reposition



tk403
11-22-2009, 04:54 AM
Hi, I have a function that repositions a photo gallery div in order to display a different section of the div when a "next" button is clicked. Won't work in Safari 4. The animate() stuff will work, but the code within the switch() statement doesn't seem to be working, because the div is not repositioning. Works fine in FF. Here's the code:


$(document).ready(function() {
$('a.gallery-switcher').click(function() {
stop();
var arrow = $(this);
$('#gallery').animate({opacity: '0'}, 'fast', function() {
var galleryPosition = parseFloat($('#gallery').css('top'), 10);
if (arrow.is('.next')) {
switch(galleryPosition) {
case 0:
galleryPosition = -705;
break;
case -705:
galleryPosition = -1410;
break;
case -1410:
galleryPosition = 0;
break;
default:
} // end switch()
} else if (arrow.is('.prev')) {
switch(galleryPosition) {
case 0:
galleryPosition = -1410;
break;
case -1410:
galleryPosition = -705;
break;
case -705:
galleryPosition = 0;
break;
default:
} // end switch()
} // end if()
$('#gallery').css('top', galleryPosition+'px');
}) // end animate()
.animate({opacity: '100'}, 'fast');
}); // end click()
});