js点击特效

 
//点击效果博客页面点击就可以看到
<script type="text/javascript"> 2 !function(e, t, a) { 3 function n() { 4 c(".heart{width: 40px;height: 40px;position: fixed;color: red;}"), o(), r() 5 } 6 7 function r() { 8 for(var e = 0; e < d.length; e++) d[e].alpha <= 0 ? (t.body.removeChild(d[e].el), d.splice(e, 1)) : (d[e].y--, d[e].scale += .004, d[e].alpha -= .013, d[e].el.style.cssText = "left:" + d[e].x + "px;top:" + d[e].y + "px;opacity:" + d[e].alpha + ";transform:scale(" + d[e].scale + "," + d[e].scale + ") rotate(0deg);color:" + d[e].color + ";z-index:99999"); 9 requestAnimationFrame(r) 10 } 11 12 function o() { 13 var t = "function" == typeof e.onclick && e.onclick; 14 e.onclick = function(e) { 15 t && t(), i(e) 16 } 17 } 18 19 function i(e) { 20 var a = t.createElement("div"); 21 var arr = ["富强","民主","文明","和谐","自由","平等","公正","法治","爱国","敬业","诚信","友善"]; 22 var i = Math.floor(Math.random()*12); 23 24 a.innerHTML = arr[i]; 25 a.className = "heart", d.push({ 26 el: a, 27 x: e.clientX - 5, 28 y: e.clientY - 5, 29 scale: 1, 30 alpha: 1, 31 color: s() 32 }), t.body.appendChild(a) 33 } 34 35 function c(e) { 36 var a = t.createElement("style"); 37 a.type = "text/css"; 38 try { 39 a.appendChild(t.createTextNode(e)) 40 } catch(t) { 41 a.styleSheet.cssText = e 42 } 43 t.getElementsByTagName("head")[0].appendChild(a) 44 } 45 46 function s() { 47 return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")" 48 } 49 var d = []; 50 e.requestAnimationFrame = function() { 51 return e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function(e) { 52 setTimeout(e, 1e3 / 60) 53 } 54 }(), n() 55 }(window, document); 56 </script>

 

转载于:https://www.cnblogs.com/facous/p/7699211.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值