Skip to content

Instantly share code, notes, and snippets.

@jtwalters
Last active December 22, 2015 18:59
Show Gist options
  • Save jtwalters/6516629 to your computer and use it in GitHub Desktop.
Save jtwalters/6516629 to your computer and use it in GitHub Desktop.
A Pen by Joel.
<div class="pulse-me">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis nulla ab id harum repellendus quae accusamus facilis sint est incidunt vero a! Maiores quis hic tempore nulla iure ipsa saepe!</div>
<button name="pulse">click me</button>

Pulse background color

A simple jQuery plugin that uses CSS3 animation to pulse the background color of any element

A Pen by Joel on CodePen.

License.

// simple pulse plugin
(function($) {
$.fn.pulse = function(options) {
options = $.extend({
delay: 2000
}, options);
this.addClass('pulse');
var that = this;
setTimeout(function() {
that.removeClass('pulse');
}, options.delay);
return this;
};
})(jQuery);
// on DOM ready
(function($) {
var pulse = function() {
$('.pulse-me').pulse();
}
$('button[name=pulse]').click(function() {
pulse();
});
pulse();
})(jQuery);
.pulse {
background-color: #ff0;
-webkit-animation-name: pulse;
-webkit-animation-duration: 0.67s;
-webkit-animation-iteration-count: 2;
-webkit-animation-direction: alternate;
-webkit-animation-timing-function: ease-in;
-webkit-animation-fill-mode: forwards;
-webkit-animation-delay: 0.67s;
}
@-webkit-keyframes pulse {
0% { background-color: #fff; }
50% { background-color: #ff0; }
100% { background-color: #fff; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment