Rotate Circle Pure Javascript
How do I make an rotate circle pure javascript?
You can rotate menu using mouse... its a pure javascript. What is a rotate circle pure javascript? How do you make a rotate circle pure javascript? This script and codes were developed by Parth Viroja on 03 September 2022, Saturday.
Rotate Circle Pure Javascript - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Rotate Circle Pure Javascript</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="ring-wrapper"> <div id="layer-1" class="ring layer-1"> <div class="ring-display"> <div class="label"><span>A</span></div> <div class="label"><span>B</span></div> <div class="label"><span>C</span></div> <div class="label"><span>D</span></div> <div class="label"><span>E</span></div> <div class="label"><span>F</span></div> <div class="label"><span>G</span></div> <div class="label"><span>H</span></div> <div class="label"><span>I</span></div> <div class="label"><span>J</span></div> <div class="label"><span>K</span></div> <div class="label"><span>L</span></div> </div> <div class="interaction"></div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>
Rotate Circle Pure Javascript - Script Codes CSS Codes
@import url(http://fonts.googleapis.com/css?family=Lato:100,200,300,400,500,600);
html { width: 100%;
}
body { background: lightcoral; padding: 50px; font-family: "Lato"; font-weight: 300;
}
.ring-wrapper { position: relative; display: block; width: 500px; height: 500px; margin: 0 auto; overflow: hidden;
}
.ring { display: block; width: 100px; height: 100px; position: absolute; top: 0; transition: transform 0.25s, box-shadow 0.25s; overflow: hidden; border-radius: 100%;
}
.ring-display { width: 100%; height: 100%; display: block; border-radius: 100%; overflow: hidden; position: absolute;
}
.interaction { width: 100%; height: 100%; display: block; border-radius: 100%; position: absolute; cursor: pointer;
}
.ring:hover + .ring { transition: box-shadow 0.25s;
}
.layer-1 { width: 500px; height: 500px; border-radius: 100%;
}
.label { top: 50%; width: 100%; height: 100%; text-align: center; transform-origin: 50% 0; position: absolute; //transform:rotate(0deg) translate(0, -50%); pointer-events: none; color: #000; text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5); line-height: 100px; font-size: 2em; transition: color 1s; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
}
.label span { display: inline-block; margin: 0 auto; width: 80px; height: 80px; line-height: 80px; background: #fff; border-radius: 50%;
}
.label:nth-child(1) { transform: rotate(0deg) translate(0, -50%); //transform: rotate(360deg) translate(0, -50%);
}
.label:nth-child(2) { transform: rotate(30deg) translate(0, -50%);
}
.label:nth-child(3) { transform: rotate(60deg) translate(0, -50%);
}
.label:nth-child(4) { transform: rotate(90deg) translate(0, -50%);
}
.label:nth-child(5) { transform: rotate(120deg) translate(0, -50%);
}
.label:nth-child(6) { transform: rotate(150deg) translate(0, -50%);
}
.label:nth-child(7) { transform: rotate(180deg) translate(0, -50%);
}
.label:nth-child(8) { transform: rotate(210deg) translate(0, -50%);
}
.label:nth-child(9) { transform: rotate(240deg) translate(0, -50%);
}
.label:nth-child(10) { transform: rotate(270deg) translate(0, -50%);
}
.label:nth-child(11) { transform: rotate(300deg) translate(0, -50%);
}
.label:nth-child(12) { transform: rotate(330deg) translate(0, -50%);
}
Rotate Circle Pure Javascript - Script Codes JS Codes
circle('layer-1'); function circle(id) { var el = document.getElementById(id); var elDisplay = el.children[0]; var elInteraction = el.children[1]; var offsetRad = null; var targetRad = 0; var previousRad; try { elInteraction.addEventListener('mousedown', down); } catch (err) { console.log("Interaction not found"); } function down(event) { offsetRad = getRotation(event); previousRad = offsetRad; window.addEventListener('mousemove', move); window.addEventListener('mouseup', up); } function move(event) { var newRad = getRotation(event); targetRad += (newRad - previousRad); previousRad = newRad; elDisplay.style.transform = 'rotate(' + (targetRad / Math.PI * 180) + 'deg)'; } function up() { window.removeEventListener('mousemove', move); window.removeEventListener('mouseup', up); } function getRotation(event) { var pos = mousePos(event, elInteraction); var x = pos.x - elInteraction.clientWidth * .5; var y = pos.y - elInteraction.clientHeight * .5; return Math.atan2(y, x); } function mousePos(event, currentElement) { var totalOffsetX = 0; var totalOffsetY = 0; var canvasX = 0; var canvasY = 0; do { totalOffsetX += currentElement.offsetLeft - currentElement.scrollLeft; totalOffsetY += currentElement.offsetTop - currentElement.scrollTop; } while (currentElement = currentElement.offsetParent) canvasX = event.pageX - totalOffsetX; canvasY = event.pageY - totalOffsetY; return { x: canvasX, y: canvasY }; } }
Developer | Parth Viroja |
Username | parthviroja |
Uploaded | September 03, 2022 |
Rating | 3 |
Size | 2,896 Kb |
Views | 44,528 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Card border collspan | 1,781 Kb |
Text Shapes | 1,928 Kb |
Custom checkbox and radio with menu | 2,288 Kb |
Slide up down | 1,833 Kb |
Ripple Effect | 2,548 Kb |
Upload Image Form | 2,689 Kb |
Css Dropdown Design | 2,096 Kb |
Filter, sort grid item | 2,592 Kb |
Right side menu tab with icon | 2,480 Kb |
3D-box | 2,346 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Comment Jquery | SquishyAndroid | 2,421 Kb |
Wave Lines | Mikehobizal | 4,023 Kb |
Responsive Minimal Blog Layout | Hackthevoid | 5,261 Kb |
Css color for svg | Ademilter | 2,392 Kb |
Twinner Spinner II | Katydecorah | 2,974 Kb |
Basic jQuery Filter list | Mtedwards | 2,464 Kb |
Single element checkbox | Ivijaygupta | 1,996 Kb |
A Pen by tugce | Ecgutcnkr | 4,197 Kb |
Improved Page Flipping Effect | Usaphp | 5,201 Kb |
Svg animation draw | SzymonDziewonski | 5,545 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!