I have a jQuery function that has been running well until recently.
//Calculate width of slider container
var calc_width = 200 * $('.side_list_cont').length;
$("#op_slide").width(calc_width);
//Calculation for when to decrease margin for slide effect
$('#op_right').click(function(){
var slidewidth = parseInt($('#op_slide').css('width'),10),
getslideleft = parseInt($('#op_slide').css('margin-left'),10),
slideleft = ((getslideleft - 200)*-1);
if ( slideleft >= slidewidth ) {
}
else {
$('#op_slide').animate({'margin-left': '-=200px'}, 200);
}
});
//Calculation for when to increase margin for slide effect
$('#op_left').click(function(){
var slidewidth = $('#op_slide').css('width'),
slideleft = $('#op_slide').css('margin-left');
if (slideleft == '0px') {
}
else {
$('#op_slide').animate({'margin-left': '+=200px'}, 200);
}
});
I used to work great. Then all of a sudden, it's not incrementing the margin-left value, but just changing it to either 200px or -200px. When looking at jQuery's docs on .animate, their example on this increment method works as it should.