zoukankan      html  css  js  c++  java
  • 雪花飘落代码

    (function($) {
        $.fn.snow = function(options) {
            var $flake = $('<div id="flake" />').css({ 'position': 'absolute', 'top': '-50px' }).html('&#10052;'),
                documentHeight = $(document).height(),
                documentWidth = $(document).width(),
                defaults = { minSize: 10, maxSize: 20, newOn: 2000, flakeColor: "red" },
                options = $.extend({}, defaults, options);
            var interval = setInterval(function() {
                    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;
                    $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() { $(this).remove() });
                },
                options.newOn);
        };
    })(jQuery);
    $.fn.snow({ minSize: 5, maxSize: 50, newOn: 2000, flakeColor: 'red' });
  • 相关阅读:
    IOS中 init和initialize
    UITableView的常用方法
    加载xib文件的两种方式
    openfire修改服务器名称方法
    POST
    ObjectiveC的动态特性
    枚举 UIButton补充
    深入ObjectiveC的动态特性 Runtime
    IOS中 类扩展 xib
    ObjectiveC语法之代码块(block)的使用
  • 原文地址:https://www.cnblogs.com/lwwen/p/10436224.html
Copyright © 2011-2022 走看看