I still don't have a hard fix on promises. Say I have a code:
selected.eq(i) // blink .fadeOut( 200 ).delay( 50 ).fadeIn( 400 ) .delay( 100 ) .fadeOut( 200 ).delay( 50 ).fadeIn( 400 );
and then I call:
selected.unbind('click') .promise().done(function () { selected.fadeOut(500); });
It works as freed - as soon as it blinks, the last fadeOut fires. But when I do the flashing through the plugin (with the option to use jQuery animation), so my whole first part is just one call:
selected.eq(i).modernBlink({ duration: 750, iterationCount: 3, auto: true} );
blinking body:
ModernBlink.prototype._fallbackAnimation = function _fallbackAnimation( iterationCount ) { var self = this, duration = this.options.duration / 2; if ( iterationCount > 0 || iterationCount === 'infinite' ) { iterationCount = iterationCount === "infinite" ? "infinite" : iterationCount - 1; this.el.animate( { 'opacity': 0 }, duration ).promise().done( function() { self.el.animate( { 'opacity': 1 }, duration ); self._fallbackAnimation( iterationCount ); }); } };
so this is a promise based recursive call. The result is different - after the first iteration from blink my code runs because my promise won.
The visual effect is to blink, fade (my part), continue to blink.
My question is - how do you say jQuery blink promises is more important than mine?
NOTE. I can’t directly bind the second part to the first part, because they are scattered throughout the code, and sometimes the first part fails.
Code flashing from Modern Blink by leonderijke. MB was used here as an example!
UPDATE: Large image, I don't know if this is useful or not, but anyway:
if (Environment.Mode=='blink') // my private settings variable call_blink(); // part 1, presented above call_fade_out(); // part 2, presented above
That’s why I can’t connect them. I have a similar "configuration" of the code used a little more, so I would like to understand and use it here and in other places.