Relative animation with multiplication
I was trying to use the core animation to reduce a set of elements in size and I think it would be nice to have a token that does multiplication. For example:
- $(selector).animate({
width : '*=0.8',
height : '*=0.8',
fontSize : '*=0.8'
}, 1000, function() {
// callback
});
The above code would reduce the object's height, width and font size by 80%. I'm a novice programmer (I still have to learn how to unit test) so I didn't want to fork github, but I put together this code for possible use (replace code starting at 6485, jQuery v1.4.4)
- // If a +=/-= token was provided, we're doing a relative animation
if ( parts[1] ) {
if (parts[1] === "*=") {
end = start * end;
} else {
end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
}
}