http://cambridgeuplighting.com/portfolio
I am trying to create a function that will fade the Next and Prev controls for a scrollTo function when the slideshow has reached either end. I have a good start but it doesn't work how I want it to. I need the controls to fade out the click BEFORE it reaches the end. Right now it reaches the end, then the next click (which will not scroll because it's at the end) will fade the control.
Here's my code, thanks alot in advance!
jQuery (please see the above link to the site for HTML and CSS)
jQuery(function( $ ){
var itemSize = $('div.portfolioPost').size();
var containerWidth = itemSize*240;
//set the width of the container depending on how many post items are there
$('#postContainer').css({'width': containerWidth })
//find the relative position of the end point by getting the negative value of the container width minus 961 (extra pixel is to account for IE difference)
var endPoint = 0-containerWidth+961;
$('.olderEvents').click(function () {
$('.newerEvents').fadeTo(350, 1.0)
var slidePos = $('#postContainer').position();
if (slidePos.left<=endPoint) {
$('.olderEvents').fadeTo(350, 0.1)
} else {
$('#slideScreen').scrollTo('+=960', 700 );
}
});
$('.newerEvents').click(function () {
$('.olderEvents').fadeTo(350, 1.0)
var slidePos = $('#postContainer').position();
//relative position of 0 means the slideshow is at the other end
if (slidePos.left==0) {
$('.newerEvents').fadeTo(350, 0.1)
} else {
$('#slideScreen').scrollTo('-=960', 700 );
}
});
});