Skip to content

Instantly share code, notes, and snippets.

@likerRr
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save likerRr/28847df2048d90de0859 to your computer and use it in GitHub Desktop.
Save likerRr/28847df2048d90de0859 to your computer and use it in GitHub Desktop.
jquery-epulse Rain Effect
<div id="rain-container"></div>
var $rain = $('<div>', {
width: '400px',
height: '400px'
});
$('#rain-container').append($rain);
var drop = $.ePulse({
container: $rain,
speed: 'fast',
size: [5, 20],
bgColor: 'blue',
reverseOpacity: true,
autoDelete: false,
forceContainerStyles: true
}, null, function afterAnimation() {
// rain effect
this.css('opacity', (Math.floor(Math.random() * 9) + 2) / 10);
this.animate({
opacity: 0
}, 8000, function() {
this.remove();
});
});
function getRandomPos() {
return Math.random() * $rain.width();
}
function startRain() {
setTimeout(function() {
drop(getRandomPos(), getRandomPos());
requestAnimationFrame(startRain)
}, Math.random() * 100);
}
startRain();
@likerRr
Copy link
Author

likerRr commented Aug 18, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment