本文主要是介绍回头看看自己3年前写的神奇雪花飘飘--好low,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//飘雪
$(function() {var minSnow = 5;var MaxSnow = 100;var speed = 900; //毫秒 var windowwidth = $(document).width();var endheight = $(document).height();var falt = $('#snow').html("❄");$(function() {task();var timer = setInterval(task, speed);$(document).click(function() { //单击事件,不再下雪console.log("stop");clearInterval(timer);timer = null;});$(document).dblclick(function(callback) { //双击事件,双击下雪console.log("go");timer = setInterval(task, speed);})});var task = function() {var opac = 0.7 + Math.random() * 0.3;var startleft = windowwidth * Math.random();var endtleft = windowwidth * Math.random();var size = minSnow + Math.random() * MaxSnow;var startleft = windowwidth * Math.random();// console.log(endheight);falt.clone().appendTo("body").css({"left": startleft,"opacity": opac,"font-size": size}).animate({"left": endtleft,"top": endheight,"opacity": 0.2,"font-size": size}, 18000, function() { $(this).remove() });}
});
效果图: (如果喜欢,随手点个赞吧,后续会分享更多有意思的东东~~~)
这篇关于回头看看自己3年前写的神奇雪花飘飘--好low的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!