Relative animation with multiplication
I posted this idea in the
jQuery Core forums; but now that I think about it, it might be better to propose the idea here since the UI adds more animation features/effects. I'm not sure how the UI core would make these changes to jQuery (I haven't looked at the UI core yet), but here is my idea.
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%. The proposed change to jQuery would replace code starting at line 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;
- }
- }