JS effects mouse click automatically displays the effect of love

JS effects mouse click automatically displays the effect of love,

 1 <script>
 2 !function(e, t, a) {
 3     function r() {
 4         for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
 5         requestAnimationFrame(r)
 6     }
 7     function n() {
 8         var t = "function" == typeof e.onclick && e.onclick;
 9         e.onclick = function(e) {
10             t && t(),
11             o(e)
12         }
13     }
14     function o(e) {
15         var a = t.createElement("div");
16         a.className = "heart",
17         s.push({
18             el: a,
19             x: e.clientX - 5,
20             y: e.clientY - 5,
21             scale: 1,
22             alpha: 1,
23             color: c()
24         }),
25         t.body.appendChild(a)
26     }
27     function i(e) {
28         var a = t.createElement("style");
29         a.type = "text/css";
30         try {
31             a.appendChild(t.createTextNode(e))
32         } catch(t) {
33             a.styleSheet.cssText = e
34         }
35         t.getElementsByTagName("head")[0].appendChild(a)
36     }
37     function c() {
38         return "rgb(" + ~~ (255 * Math.random()) + "," + ~~ (255 * Math.random()) + "," + ~~ (255 * Math.random()) + ")"
39     }
40     var s = [];
41     e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame ||
42     function(e) {
43         setTimeout(e, 1e3 / 60)
44     },
45     i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),
46     n(),
47     r()
48 } (window, document);
49 </script>

how to use?

Copy the code above to your website at the bottom you can, you can own and then create a new one js file storage. See your mood slightly ~footer FVDI J2534 

Haha, this is so brief. .

ok, Benpian finished, thank you for reading this switched-: https://www.chinaobd2.com/

 

Guess you like

Origin www.cnblogs.com/cannovo/p/10965402.html