The code ...
// If a +/- token was provided, we're doing a relative animation if ( parts[1] ) end = ((parts[1] == "-" ? -1 : 1) * end) + start; ... is based on the assumption that any value with a leading +/- indicator is a relative animation. Unfortunately this means that it can't (currently!) cope with absolute animation in a negative range. For example, if you want to animate anything from currentValue TO -y it will translate that into animate from currentValue BY -y, simply because of the negative sign in front of y. With positives, in mathematical terms x (unsigned) is equivalent to +x, so purposefully inserting a plus sign could be interpreted as a relative movement as opposed to a positive absolute. However, you can only get relative changes to be recognised by sending a String, ie. {top:+234} will be taken as absolute, whereas {top:'+234'} will be taken as relative. This is because (at least in Firefox!) the number loses the plus sign as being irrelevant, so conversion to String for pattern recognition of the leading '+' will never have a leading '+'! This leaves 2 questions: 1. How do you get around it until it's fixed? 2. How do you fix it? (1) Work-around. There are 2 ways (I think). Either: Try sending the change through as a String with a leading space, eg instead of animate({marginTop:-2492}), try animate({marginTop:' -2492'}). (This worked for me in a very simple test) Or: Translate any absolute movement to a negative position into a relative movement before calling animate, eg. get current marginTop yourself and work out the relative change required (2) Fix. Hmmm. There are undoubtedly lots of possible solutions and I hesitate to suggest one in favour of any other, but ... seeing as a String has to be used to get the leading '+' sign recognised, why not make relative changes be enforced by a double sign. For example: animate({top:234}) = absolute change to 234px animate({top:'+234em'}) = absolute change to 234em animate({top:-234}) = absolute change to -234px animate({top:'-234%'}) = absolute change to -234% animate({top:'++234'}) = relative change by 234px animate({top:'+-234'}) = relative change by -234px animate({top:'--234em'}) = relative change by -234em animate({top:'-+234%'}) = relative change by +234% [ NB 'double-signing' numbers: animate({top:++234}) = javascript error, invalid increment operand animate({top:--234}) = javascript error, invalid decrement operand animate({top:+-234}) = absolute change to -234px animate({top:-+234}) = absolute change to -234px ] In the above examples, the direction of the first sign doesn't matter - it could be a '+' or a '-', all it does is indicate that the change is relative. For that matter, it could be something else, like an 'r' instead of a +/-, eg animate({top:'r234'}) or animate({top:'r-234'}), but I'm not sure whether that might not be more confusing. Allowing either a '+' or a '-' could allow users to more easily apply the 'relative' directive depending upon how they work out and construct their values. Anyway, to make this 'double-signing' work would require 2 changes (v1.2 source): At roughly line 2578... // var parts = val.toString().match(/^([+-]?)([\d.]+)(.*)$/), var parts = val.toString().match(/^([+-]*?)([\d.]+)(.*)$/), And roughly 2592... // If 'double-signed', we're doing a relative animation if ( parts[1] ) // end = ((parts[1] == "-" ? -1 : 1) * end) + start; end = ((parts[1].substr(parts[1].length-1) == "-" ? -1 : 1) * end) + (parts[1].length>1 ? start : 0); As I stated at the start, this is only a suggestion and may turn out to be non-viable in the bigger picture - but it does seem to work (bearing in mind I'm only testing in Firefox!). bmsterling wrote: > > Not sure if this is any more help, but looking at the core around line > 2593, > it looks like you check for a minus sign and then add that to the start > position/style and your comments says: > > "// If a +/- token was provided, we're doing a relative animation" > > But yet you are not looking, explicitly, for a plus sign. > > Well, hope this helps in some way. > > On 9/11/07, Benjamin Sterling <[EMAIL PROTECTED]> wrote: >> >> Will do, I also just did some testing and it looks like it happens when a >> minus sign is in play. I will post my findings to the bug report. >> >> On 9/11/07, John Resig <[EMAIL PROTECTED]> wrote: >> > >> > >> > Sounds like a true bug. Could you submit a bug report? >> > http://dev.jquery.com/ >> > >> > --John >> > >> > On 9/11/07, Benjamin Sterling <[EMAIL PROTECTED]> wrote: >> > > Url in question: >> > > http://benjaminsterling.com/experiments/jqGalViewV2/ >> > > >> > > At about line 87 and then again at line 91 I have the following: >> > > >> > > >> > $holder.animate({marginTop:-($mainImgContainer.height()*index)},'1000', >> > > opts.tnease); >> > > >> > > Depending on the link at bottom clicked, the marginTop gets set to >> > what ever >> > > $mainImgContainer.height()*index adds up to, but with a >> > > minus infront. So if you click on eight you get -2492. And when you >> > > clicked 7, you would get -2136. In 1.1.3 this worked fine[1]. But >> > with 1.2 >> > > it will just add up the marginTop, so -2492 and -2136 becomes -4628. >> > > >> > > In an earlier post, John[2] suggested that the animation method only >> > took in >> > > integers, so if I do: >> > > >> > > >> > >> $holder.animate({marginTop:parseInt(-($mainImgContainer.height()*index))},'1000', >> > >> > > opts.tnease); >> > > >> > > It should work, but sadly, still adds up. Is this a true bug, or am >> I >> > > missing something? >> > > >> > > [1] http://benjaminsterling.com/experiments/jqGalView >> > > [2] >> > > >> http://groups.google.com/group/jquery-en/browse_thread/thread/705cd47864c22c49/485702b3f03547c5#485702b3f03547c5 >> > >> > > -- >> > > Benjamin Sterling >> > > http://www.KenzoMedia.com >> > > http://www.KenzoHosting.com >> > >> >> >> >> -- >> Benjamin Sterling >> http://www.KenzoMedia.com >> http://www.KenzoHosting.com >> > > > > -- > Benjamin Sterling > http://www.KenzoMedia.com > http://www.KenzoHosting.com > > -- View this message in context: http://www.nabble.com/Animation-bug-in-1.2-tf4426383s15494.html#a12634375 Sent from the JQuery mailing list archive at Nabble.com.