Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.     $.fn.snow = function (options) {
  3.         var $flake = $('<div id="flake" />').css({'position': 'absolute', 'top': '-50px'}).html('&#10052;'), documentHeight = $(document).height(), documentWidth = $(document).width(), defaults = {minSize: 10, maxSize: 20, newOn: 500, flakeColor: "#FFFFFF"}, options = $.extend({}, defaults, options);
  4.         var interval = setInterval(function () {
  5.             var startPositionLeft = Math.random() * documentWidth - 100, startOpacity = 0.5 + Math.random(), sizeFlake = options.minSize + Math.random() * options.maxSize, endPositionTop = documentHeight - 40, endPositionLeft = startPositionLeft - 100 + Math.random() * 200, durationFall = documentHeight * 10 + Math.random() * 5000;
  6.             $flake.clone().appendTo('body').css({left: startPositionLeft, opacity: startOpacity, 'font-size': sizeFlake, color: options.flakeColor}).animate({top: endPositionTop, left: endPositionLeft, opacity: 0.2}, durationFall, 'linear', function () {
  7.                 $(this).remove()
  8.             });
  9.         }, options.newOn);
  10.     };
  11. })(jQuery);
  12. $(window).load(function () {
  13.     $.fn.snow({minSize: 2, maxSize: 5, newOn: 80, flakeColor: '#ffffff'});
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement