Last active
December 26, 2015 11:29
-
-
Save CreativeNotice/7144598 to your computer and use it in GitHub Desktop.
Simple function to pulsate element using jQuery animate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* pulsar | |
* @description Will change the element's opacity in a recursing manner. | |
* @param {Object} elm A DOM or jQuery element object | |
* @param {Object} options Options to override defaults, see var settings for those available | |
* @return {Void} | |
* | |
* @see jQuery.animate http://api.jquery.com/animate/ | |
*/ | |
var pulsar = function( elm, options ) { | |
// Set our defaults | |
var settings = $.extend({ | |
prop_start: { opacity: 0.4 }, | |
prop_end: { opacity: 1 }, | |
duration: 1000, | |
easing: 'linear' | |
}, options ); | |
// Animate that element | |
$( elm ).animate( settings.prop_start, settings.duration, settings.easing, function(){ | |
$(this).animate( settings.prop_end, settings.duration, settings.easing, pulsar(this) ); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment