Currently, I am encountering an issue where I am unable to configure the Jquery rotator from
Easy Jquery Auto Image Rotator and script source Google jquery.min.js
I attempted to give the second gallery a different class and duplicated the js script.
Then, I replaced all the class and selector names with the second gallery.
However, only one of the galleries works, and I am seeking a solution that can encompass
both galleries with one function.
Additionally, I tried to use only one function and input both div ids into the (id) sections
-> which did not work. Now, both layers are stacked on top of each other, and I am unable to move them
by assigning float:left and float:right.
I would greatly appreciate your assistance.
Thank you in advance.
These are the divs:
<div class="rotator">
<ul>
<li class="show"><img src="img/screenshots/screen1-big.jpg" alt="pic1" /></li>
<li><img src="img/screenshots/screen2-big.jpg" alt="pic2" /></li>
<li><img src="img/screenshots/screen3-big.jpg" alt="pic3" /></li>
<li><img src="img/screenshots/screen4-big.jpg" alt="pic4" /></li>
</ul>
</div>
</div>
<div class="wrapper">
<div class="gallery">
<ul>
<li class="take"><img src="img/screenshots/screen3.jpg" alt="pic1" /></li>
<li><img src="img/screenshots/screen2.jpg" alt="pic2" /></li>
<li><img src="img/screenshots/screen4.jpg" alt="pic3" /></li>
<li><img src="img/screenshots/screen1.jpg" alt="pic4" /></li>
</ul>
</div>
</div>
These are the div classes
/* rotator in-page placement */
div.rotator {display:none; float:left; width: 451px;}
/* rotator css */
div.rotator ul { margin:0; padding:0;}
div.rotator ul li { position:absolute; list-style: none;}
/* rotator image style */
div.rotator ul li img {width:451px; height: 313px;}
div.rotator ul li.show {z-index:500;}
div.gallery {display:none; float:right; width: 451px;}
/* rotator css */
div.gallery ul { margin:0; padding:0;}
div.gallery ul li { position:absolute; list-style: none;}
/* rotator image style */
div.gallery ul li img {width:451px; height:313px;}
div.gallery ul li.take {z-index:500;}
Function 1 for the rotator div
function theRotator() {
//Set the opacity of all images to 0
$('div.rotator ul li').css({opacity: 0.0});
//Get the first image and display it (gets set to full opacity)
$('div.rotator ul li:first').css({opacity: 1.0});
//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
if ($('div.rotator ul li').length > 1) {
setTimeout('rotate()', 6000);
}
}
function rotate() {
//Get the first image
var current = ($('div.rotator ul li.show')? $('div.rotator ul li.show') : $('div.rotator ul li:first'));
if (current.length == 0 ) current = $('div.rotator ul li:first');
//Get next image, when it reaches the end, rotate it back to the first image
var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));
//Un-comment the 3 lines below to get the images in random order
//var sibs = current.siblings();
//var rndNum = Math.floor(Math.random() * sibs.length );
//var next = $( sibs[ rndNum ] );
//Set the fade in effect for the next image, the show class has higher z-index
next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
//Hide the current image
current.animate({opacity: 0.0}, 1000, function(){setTimeout('rotate()', 6000);}) .removeClass('show');
};
$(document).ready(function() {
//Load the slideshow
theRotator();
$('div.rotator').fadeIn(1000);
$('div.rotator ul li').fadeIn(1000); // tweek for IE
});
Function 2 for the gallery div
function theGalley() {
//Set the opacity of all images to 0
$('div.gallery ul li').css({opacity: 0.0});
//Get the first image and display it (gets set to full opacity)
$('div.gallery ul li:first').css({opacity: 1.0});
//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
if ($('div.gallery ul li').length > 1) {
setTimeout('rotate()', 6000);
}
}
function rotate() {
//Get the first image
var current = ($('div.gallery ul li.take')? $('div.gallery ul li.take') : $('div.gallery ul li:first'));
if (current.length == 0 ) current = $('div.gallery ul li:first');
//Get next image, when it reaches the end, rotate it back to the first image
var next = ((current.next().length) ? ((current.next().hasClass('take')) ? $('div.gallery ul li:first') :current.next()) : $('div.gallery ul li:first'));
//Un-comment the 3 lines below to get the images in random order
//var sibs = current.siblings();
//var rndNum = Math.floor(Math.random() * sibs.length );
//var next = $( sibs[ rndNum ] );
//Set the fade in effect for the next image, the show class has higher z-index
next.css({opacity: 0.0}).addClass('take').animate({opacity: 1.0}, 1000);
//Hide the current image
current.animate({opacity: 0.0}, 1000, function(){setTimeout('rotate()', 6000);}) .removeClass('take');
};
$(document).ready(function() {
//Load the slideshow
theGallery();
$('div.gallery').fadeIn(1000);
$('div.gallery ul li').fadeIn(1000); // tweek for IE
});