-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextFlower.js
25 lines (24 loc) · 1.32 KB
/
textFlower.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function Defint(DEFINE, INPUT) {
var RESULT = {};
for (var vlaue in DEFINE) { RESULT[vlaue] = DEFINE[vlaue]; }
for (var vlaue in INPUT) { RESULT[vlaue] = INPUT[vlaue]; }
return RESULT;
}
function TextFlower(DATA) {
var THISDATA = Defint({ FONTWEIGHT: 700, FONTSIZE: 15, TEXTARRAY: ['嘿嘿嘿', '哈哈哈', '呵呵呵', '么么哒', '吼吼吼'], COLORARRAY: ["palegreen", "paleturquoise", "tomato", "palevioletred", "teal", "pink", "hotpink"] }, DATA);
var clickAain = true;
$(window).click(function (e) {
if (clickAain) {
clickAain = false;
var span = $("<span style='pointer-events:none;user-select:none;position:fixed;z-index:30;font-size:" +
THISDATA.FONTSIZE + "px;font-weight:" + THISDATA.FONTWEIGHT + ";color:" +
THISDATA.COLORARRAY[Math.floor(Math.random() * THISDATA.COLORARRAY.length)] + "'>" +
THISDATA.TEXTARRAY[Math.floor(Math.random() * THISDATA.TEXTARRAY.length)] + "</span>");
$("body").append(span)
span.css({ "top": e.pageY - 15, "left": e.pageX - (parseInt(span.css("width")) / 2) });
span.animate({ top: "-=35", "opacity": "0", }, 1000);
setTimeout(function () { span.remove(); }, 1500);
setTimeout(function () { clickAain = true; }, 30);
}
})
}