I am developing an image gallery with photos sliding left
and right
on mouse scroll up
and scroll down
respectively.
The gallery with 5 photos looks like this:
http://www.games07.tk/Untitled.png
Function:
function scrollPhotosLeft()
{
$(".photo0").switchClass("photo0","photo1",500);
$(".photo1").switchClass("photo1","photo2",500);
$(".photo2").switchClass("photo2","photo4",500);
$(".photo3").switchClass("photo3","photo0",500);
$(".photo4").switchClass("photo4","photo3",500);
}
function scrollPhotosRight()
{
$(".photo0").switchClass("photo0","photo3",500);
$(".photo1").switchClass("photo1","photo0",500);
$(".photo2").switchClass("photo2","photo1",500);
$(".photo3").switchClass("photo3","photo4",500);
$(".photo4").switchClass("photo4","photo2",500);
}
CSS:
.photo0{
top: 50%;
left: 50%;
}
.photo1{
top: 40%;
left: 30%;
}
.photo2{
top: 30%;
left: 10%;
}
.photo3{
top: 40%;
left: 70%;
}
.photo4{
top: 30%;
left:90%;
}
Scrolling down causes no problem but in some conditions scrolling down and suddenly scrolling up causes the photos to look like this:
http://www.games07.tk/Untitled2.png
Is there any way to overcome this problem or any other way to implement this?
I had noticed that after some combination of scrolling up and down the switchClass() is giving same class for images (got this from Google Chrome Inspect Element)