0

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.

1 Answer 1

4

Did you recently upgrade to jQuery 1.10.0? If so, the relative incremental animation issue (e.g. .animate({'margin-left': '+=200px'}) was a bug in that version that was just fixed today in 1.10.1.

See: http://blog.jquery.com/2013/05/30/jquery-1-10-1-and-2-0-2-released/ and http://bugs.jquery.com/ticket/13939

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, I'm linked to latest. It's an old Joomla build that uses a module. ...ugh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.