I'm creating a sliding image gallery using jQuery and when given a numeric value the "left" css property works fine, but when given a variable it doesn't do anything. Here's my code:
$(document).mousemove(function(e) {
var gall = document.getElementById("Gallery");
var gallOffset = $("div#GalleryHold").offset();
var offsetX = e.pageX - gallOffset.left;
var left = gall.style.posLeft;
var pos = offsetX;
if (mouseIsOver == true) {
$('#status').html(offsetX + " " + left + " " + mouseIsOver);
if (offsetX < 400 && left < 0) {
$("div#Gallery").stop().animate({
left: '+=pos'
}, 600);
}
if (offsetX > 600 && left > -1100) {
$("div#Gallery").stop().animate({
left: '-=pos'
}, 600);
}
}
else if (mouseIsOver == false) {
$('#status').html(offsetX + " " + left + " " + mouseIsOver);
}
});
animate({left: '+=pos'}doesnt work?{left: '+=' + pos}