Opened 12 years ago
Closed 12 years ago
#7616 closed enhancement (fixed)
Document and clean arguments of per-step callback in animate()
Reported by: | checat | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | effects | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Currently animate() can animate only simple numeric CSS properties.
Animate options has a 'step' callback. It could be used to create any custom animation, but its parameters and usage are not properly documented (http://api.jquery.com/animate/). Currently it is called once for every animated CSS property and it is not called when no CSS properties given. Its first parameter is a numeric value of animated property.
Anyway, one can make use of it, using second argment, but it looks more like a hack. Following snippet animates text color from black to red:
jQuery('div').animate({opacity: 1}, { duration: 'slow', step: function (now, fx) { jQuery(this).css('color', 'rgb(' + Math.round(fx.pos*255) + ',0,0)'); }});
I think, exposed callback should have first parameter showing current animation 'completeness' (fx.pos, not fx.now), and it should be called only once per animation step no matter how many properties are animated, even 0 properties.
Change History (5)
comment:1 follow-up: 2 Changed 12 years ago by
Component: | unfiled → effects |
---|---|
Keywords: | needsdocs added |
Milestone: | 1.5 → 1.4.5 |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 12 years ago by
Replying to jitter:
The proposed enhancements to the step function don't look necessary to me
How about "it should be called only once per animation step no matter how many properties are animated"? Currently animate() makes quick exit when there are no properties (first arg is empty), and step function is not called at all in that case.
comment:4 Changed 12 years ago by
comment:5 Changed 12 years ago by
Keywords: | needsdocs removed |
---|---|
Resolution: | → fixed |
Status: | open → closed |
The resolution for this ticket (based on the original discussion above) appears to have been that it required better documentation in order for it to be closed. As per jitter, I don't think the proposed enhancements are that necessary. With this in mind I've updated the animate()/step docs accordingly to reflect some clearer verbiage on how .step() actually works. http://api.jquery.com/animate/
I agree that this needs to be better documented.
The proposed enhancements to the step function don't look necessary to me as the second parameter
fx
contains just about everything you could need. e.g.completeness
-->fx.state
.