Created
May 28, 2013 02:02
-
-
Save LibertysYarn/5660091 to your computer and use it in GitHub Desktop.
Smoke
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
#viewport { | |
position: relative; | |
width: 800px; | |
height: 600px; | |
overflow: hidden; | |
background:url('images/milk_tea.jpg') 0 0 no-repeat | |
} | |
#viewport .smoke { | |
position: absolute; | |
width: 250px; | |
height: 250px; | |
background:url('images/smoke-texture.png') no-repeat; | |
bottom: 150px; | |
margin-left:0px | |
} |
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
<script type="text/javascript"> | |
$(function () { | |
if (!$.browser.msie) { | |
var a = 0; | |
for (; a < 15; a += 1) { | |
setTimeout(function b() { | |
var a = Math.random() * 1e3 + 5e3, | |
c = $(" | |
", { | |
"class": "smoke", | |
css: { | |
opacity: 0, | |
left: Math.random() * 200 + 80 | |
} | |
}); | |
$(c).appendTo("#viewport"); | |
$.when($(c).animate({ | |
opacity: 1 | |
}, { | |
duration: a / 4, | |
easing: "linear", | |
queue: false, | |
complete: function () { | |
$(c).animate({ | |
opacity: 0 | |
}, { | |
duration: a / 3, | |
easing: "linear", | |
queue: false | |
}) | |
} | |
}), $(c).animate({ | |
bottom: $("#viewport").height() | |
}, { | |
duration: a, | |
easing: "linear", | |
queue: false | |
})).then(function () { | |
$(c).remove(); | |
b() | |
}) | |
}, Math.random() * 3e3) | |
} | |
} else { | |
"use strict"; | |
var a = 0; | |
for (; a < 15; a += 1) { | |
setTimeout(function b() { | |
var a = Math.random() * 1e3 + 5e3, | |
c = $(" | |
", { | |
"class": "smoke", | |
css: { | |
left: Math.random() * 200 + 80 | |
} | |
}); | |
$(c).appendTo("#viewport"); | |
$.when($(c).animate({}, { | |
duration: a / 4, | |
easing: "linear", | |
queue: false, | |
complete: function () { | |
$(c).animate({}, { | |
duration: a / 3, | |
easing: "linear", | |
queue: false | |
}) | |
} | |
}), $(c).animate({ | |
bottom: $("#viewport").height() | |
}, { | |
duration: a, | |
easing: "linear", | |
queue: false | |
})).then(function () { | |
$(c).remove(); | |
b() | |
}) | |
}, Math.random() * 3e3) | |
} | |
} | |
}())</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment