I’d like to somehow get the target opacity (the final value it is being animated to) of an element that is fading.
For example…
$('body').fadeTo(0.4); // 0.4
$('body').fadeIn(); // 1
$('body').fadeOut(); // 0
$('body').animate({ opacity: 0.7 }); // 0.7
Is this doable in jQuery?
Update
For some background, see my answer here on Stack Overflow. I was trying to help out another user on SO and decided to ask this question that related to my answer.
jQuery uses step functions internally, you can overwrite the
jQuery.fx.step.opacityfunction to read the passedjQuery.fxobject:The opacity step function is called on every step of every opacity animation. You would probably want to filter the above based on
fx.elem.fx.endis the final value of the animation,fx.nowis the current value andfx.startis the starting value.fx.unitis the unit of the values (in px, em, %, etc).