JS follows mouse cursor effects (source code)

Preface

This special effect has been online for a long time. (initial's Blog) Only then can you see that when the mouse moves, there will be a colorful little star to follow. It is also a very special way to increase the interest of blogs. It can be seen that it is not used in blogs, because the conflict between mobile terminals is not appropriate. But everyone's blog is different. Maybe it's right for you.

Effect preview


Demonstration station: JS mouse follows special effects

Create JS file

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 /**
Template Name: sliding small star 
Blog:http://mlldxe.cn/
author:'s
url: dog ('s
url: {
var) possibleColors (= "#D61C59", "#E7D84B", "#E7D84B", "=", "=", "=", "=", "="; "="; ";"; "#D61C59"; "#E7D84B"; "="; "2", "0"; ";"; ClientX, e.touches[i].clientY, possibleColors[Math.floor (Math.random (* * possibleColors.length)]) 
}
}
}

function onMouseMove (E) {
cursor.x = e.clientX; 
cursor.y = = (f); (0); (1); (possibleColors[Math.floor); (possibleColors[Math.floor) = (2); ((x) = (0); ()); ((1)); "Block", "pointerEvents": "pointerEvents": "pointerEvents": "Z-index": "Z-index": "99999999", "fontSize": "fontSize": "fontSize": "Hou", "Yu", "{"}; "=" (","); (= ((), "0.5": 1) * ("(") / 2), * ("(")) / 2 "," {"}";.LifeSpan = 200; 
this.initialStyles = {} "position": "fixed", "top": "0", "display". + = this.velocity.y; 
this.lifeSpan--; 
this.element.style.transform = "translate3d (" + this.position.x + "PX", "+ this.position.y +" Px, 0) scale ("+ (this.lifeSpan / 120) +") "
}
this.die = scale () {"} "(") "," * "," (","), "(", ").

Usage method

Add this code (compressible)

 One
 < Script SRC = "Http://blog.mlldxe.cn/cursor-effects.js" > 

Download address

Download locally


"Original article, welcome to reprint. Reprint please note: reprinted Mlldxe's Blog Thank you!
The original link address: JS follows mouse cursor effects (source code)
Give the thumbs-up

Comment

E-mail addresses will not be made public. Required items have been used. * Tagging