Last active
August 29, 2015 14:27
-
-
Save likerRr/28847df2048d90de0859 to your computer and use it in GitHub Desktop.
jquery-epulse Rain Effect
This file contains hidden or 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
<div id="rain-container"></div> |
This file contains hidden or 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
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo