-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
42 lines (42 loc) · 1.79 KB
/
start.js
File metadata and controls
42 lines (42 loc) · 1.79 KB
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
"use strict";
const createSVG = (width, height, radius) => {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
const rectangle = document.createElementNS("http://www.w3.org/2000/svg", "rect");
svg.setAttributeNS("http://www.w3.org/2000/svg", "viewBox", `0 0 ${width} ${height}`);
rectangle.setAttribute("x", "0");
rectangle.setAttribute("y", "0");
rectangle.setAttribute("width", "100%");
rectangle.setAttribute("height", "100%");
rectangle.setAttribute("rx", `${radius}`);
rectangle.setAttribute("ry", `${radius}`);
rectangle.setAttribute("pathLength", "10");
svg.appendChild(rectangle);
return svg;
};
document.querySelectorAll(".CharacterButton").forEach((button) => {
const htmlButton = button;
const style = getComputedStyle(htmlButton);
const lines = document.createElement("div");
lines.classList.add("lines");
const groupTop = document.createElement("div");
const groupBottom = document.createElement("div");
const svg = createSVG(htmlButton.offsetWidth, htmlButton.offsetHeight, parseInt(style.borderRadius, 10));
groupTop.appendChild(svg);
groupTop.appendChild(svg.cloneNode(true));
groupTop.appendChild(svg.cloneNode(true));
groupTop.appendChild(svg.cloneNode(true));
groupBottom.appendChild(svg.cloneNode(true));
groupBottom.appendChild(svg.cloneNode(true));
groupBottom.appendChild(svg.cloneNode(true));
groupBottom.appendChild(svg.cloneNode(true));
lines.appendChild(groupTop);
lines.appendChild(groupBottom);
button.appendChild(lines);
button.addEventListener("pointerenter", () => {
button.classList.add("start");
});
svg.addEventListener("animationend", () => {
button.classList.remove("start");
});
});
//# sourceMappingURL=start.js.map