MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / animate

Function animate

assets/js/circleAnimation.js:5–29  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

3
4// Event-Handler Function
5function animate(event) {
6 let circle = document.createElement("circle"); //Creating a <circle> element
7 circle.setAttribute("class", "circle"); //Adding the <class> attribute to the <circle> element
8 document.body.appendChild(circle); //Inserting <circle> to DOM
9
10 circle.style.left = event.clientX + 'px';
11 circle.style.top = event.clientY + 'px';
12
13 var color = colors[Math.floor(Math.random() * colors.length)]; //Assigning colors to circle borders randomly
14 circle.style.borderColor = color;
15
16 //Adding animation to the circles
17 circle.style.transition = "all 0.5s linear 0s";
18
19 circle.style.left = circle.offsetLeft - 20 + 'px';
20 circle.style.top = circle.offsetTop - 20 + 'px';
21
22 circle.style.color = color;
23 circle.style.width = "35px";
24 circle.style.height = "35px";
25 circle.style.borderWidth = "10px";
26 circle.style.opacity = 0;
27
28
29}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected