-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathjquery.firefly.min.js
11 lines (10 loc) · 1.54 KB
/
jquery.firefly.min.js
1
2
3
4
5
6
7
8
9
10
11
/*
* jQuery Firefly v0.1
* https://github.com/motyar/firefly
* Licensed under the MIT license.
* Copyright 2011 Dharmveer Motyar
* http://motyar.blogspot.com
*/
(function($){var defaults={images:["http://dharmmotyar.googlecode.com/svn/trunk/images/spark.png","http://dharmmotyar.googlecode.com/svn/trunk/images//spark2.png","http://dharmmotyar.googlecode.com/svn/trunk/images/spark3.png","http://dharmmotyar.googlecode.com/svn/trunk/images/spark4.png"],total:40};$.firefly=function(settings){$.firefly.settings=$.extend({},defaults,settings);if($.firefly.preloadImages())for(i=0;i<$.firefly.settings.total;i++)$.firefly.fly($.firefly.create($.firefly.settings.images[$.firefly.random($.firefly.settings.images.length)]));
return};$.firefly.create=function(img){spark=$("<img>").attr({"src":img}).hide();$(document.body).append(spark);return spark.css({"position":"absolute","z-index":$.firefly.random(20),top:$.firefly.random($(window).height()-150),left:$.firefly.random($(window).width()-150)}).show()};$.firefly.fly=function(sp){$(sp).animate({top:$.firefly.random($(window).height()-150),left:$.firefly.random($(window).width()-150),opacity:$.firefly.opacity()},($.firefly.random(10)+5)*1100,function(){$.firefly.fly(sp)})};
$.firefly.preloadImages=function(){var preloads=new Object;for(i=0;i<$.firefly.settings.images.length;i++){preloads[i]=new Image;preloads[i].src=$.firefly.settings.images[i]}return true};$.firefly.random=function(max){return Math.ceil(Math.random()*max)-1};$.firefly.opacity=function(){op=Math.random();if(op<0.2)return 0;else return 1}})(jQuery);