Degree Picker
How do I make an degree picker?
What is a degree picker? How do you make a degree picker? This script and codes were developed by Kasper Mikiewicz on 21 November 2022, Monday.
Degree Picker - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Degree Picker</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html { min-height: 100%; background-image: linear-gradient(45deg, rgba(194, 233, 221, 0.5) 1%, rgba(104, 119, 132, 0.5) 100%), linear-gradient(-45deg, #494d71 0%, rgba(217, 230, 185, 0.5) 80%);
}
body { font-family: "Open Sans"; text-align: center; margin: 3em 1em;
}
.radius-picker-wrap { user-select: none; border-radius: 50%; width: 10em; height: 10em; display: inline-block; box-shadow: 0 1px 5px rgba(0,0,0, .1), 0 2px 5px rgba(0,0,0, .17) inset; border: 1px solid #bfbfbf; background: linear-gradient(to bottom, #ffffff 0%,#dfdfdf 100%);
}
.radius-picker { display: inline-block; margin: 0; position: relative; border-radius: inherit; margin: 10%; width: 80%; height: 80%; box-sizing: border-box; box-shadow: 0 1px 3px rgba(0,0,0, .1), 0 0 2px rgba(0,0,0, .5) inset; background: #00bded;
}
.radius-picker:after { content: ''; width: 95%; height: 95%; margin: 2.5%; background: #e8e8e8; display: block; border-radius: 50%;
}
.radius-picker__handle { width: 1em; height: 1em; top: 50%; left: 50%; margin: -.65em 0 0 -.65em; border-radius: 50%; background: #e86d4e; border: 1px solid #c75437; display: inline-block; box-shadow: 0 1px 2px rgba(0,0,0, .51), 0 1px 0 rgba(255,255,255, .25) inset; position: absolute; z-index: 1; cursor: pointer;
}
.radius-picker__value { text-align: center; position: absolute; top: 50%; left: 50%; letter-spacing: -.1em; border: 1px solid #a5a5a5; margin-top: -.7em; width: 2.5em; height: 2.5em; line-height: 2.5em; border-radius: 50%; margin-top: -1.25em; margin-left: -1.25em; font-size: 1.25em; color: #808a96; box-shadow: 0 1px 0 white;
}
.radius-picker__value:after { font-weight: normal; content: "\00b0";
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
<div class="radius-picker-wrap"> <div class="radius-picker js-radius-picker" data-degree="28"> <i class="radius-picker__handle"></i> <span class="radius-picker__value"></span> </div>
</div>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/script.js" type="text/javascript"></script> <script src="js/index.js"></script>
</body>
</html>
Degree Picker - Script Codes CSS Codes
html { min-height: 100%; background-image: linear-gradient(45deg, rgba(194, 233, 221, 0.5) 1%, rgba(104, 119, 132, 0.5) 100%), linear-gradient(-45deg, #494d71 0%, rgba(217, 230, 185, 0.5) 80%);
}
body { font-family: "Open Sans"; text-align: center; margin: 3em 1em;
}
.radius-picker-wrap { user-select: none; border-radius: 50%; width: 10em; height: 10em; display: inline-block; box-shadow: 0 1px 5px rgba(0,0,0, .1), 0 2px 5px rgba(0,0,0, .17) inset; border: 1px solid #bfbfbf; background: linear-gradient(to bottom, #ffffff 0%,#dfdfdf 100%);
}
.radius-picker { display: inline-block; margin: 0; position: relative; border-radius: inherit; margin: 10%; width: 80%; height: 80%; box-sizing: border-box; box-shadow: 0 1px 3px rgba(0,0,0, .1), 0 0 2px rgba(0,0,0, .5) inset; background: #00bded;
}
.radius-picker:after { content: ''; width: 95%; height: 95%; margin: 2.5%; background: #e8e8e8; display: block; border-radius: 50%;
}
.radius-picker__handle { width: 1em; height: 1em; top: 50%; left: 50%; margin: -.65em 0 0 -.65em; border-radius: 50%; background: #e86d4e; border: 1px solid #c75437; display: inline-block; box-shadow: 0 1px 2px rgba(0,0,0, .51), 0 1px 0 rgba(255,255,255, .25) inset; position: absolute; z-index: 1; cursor: pointer;
}
.radius-picker__value { text-align: center; position: absolute; top: 50%; left: 50%; letter-spacing: -.1em; border: 1px solid #a5a5a5; margin-top: -.7em; width: 2.5em; height: 2.5em; line-height: 2.5em; border-radius: 50%; margin-top: -1.25em; margin-left: -1.25em; font-size: 1.25em; color: #808a96; box-shadow: 0 1px 0 white;
}
.radius-picker__value:after { font-weight: normal; content: "\00b0";
}
Degree Picker - Script Codes JS Codes
/* ============================================= * * http://designitcodeit.com - more awesome stuff * * ============================================= */
var DegreePicker = function(el, opts) { var defaults = { /** * Degrees step * @type {Number} */ step: 1, /** * Function called after degree update * @param {DOM Element} self Picker * @param {Number} degree */ callback: function(self, degree) {} }; opts = opts || {}; for (var property in defaults) { if (!opts[property]) opts[property] = defaults[property]; } var _ = { container: { el: null, x: null, y: null, radius: null, center: { x: null, y: null } }, handle: { el: null, x: null, y: null, size: 0, position: function(of) { return Math.round(_.container.radius * Math[of === 'x' ? 'cos' : 'sin' ](Math.atan2(_.handle.y, _.handle.x))); } }, degree: { el: null, value: null, get: function() { return Math.round(this.value); }, update: function() { this.value = Math.atan2(_.handle.y * -1, _.handle.x) * 180 / Math.PI; this.value += this.value < 0 ? 360 : 0; }, set: function(value) { value = value > 180 ? value - 360 : value; value = value * Math.PI / 180; _.handle.x = Math.cos(value); _.handle.y = -Math.sin(value); _.move(); } }, isDragging: false, init: function() { _.container.el = document.querySelector(el); _.container.x = _.container.el.offsetLeft; _.container.y = _.container.el.offsetTop; _.container.radius = _.container.el.offsetWidth / 2; _.updateElementCenter(); _.handle.el = _.container.el.children[0]; _.handle.size = _.handle.el.offsetWidth; _.degree.el = _.container.el.children[1]; _.degree.set(_.container.el.getAttribute('data-degree') || 0); // Bind events _.handle.el.addEventListener('mousedown', _.onMouseDown); window.addEventListener('mouseup', _.onMouseUp); window.addEventListener('mousemove', _.onMouseMove); window.addEventListener('resize', _.updateElementCenter); }, /* Events *************************************/ onMouseDown: function(event) { _.isDragging = true; _.updateCoords(event); _.move(); }, onMouseUp: function() { _.isDragging = false; }, onMouseMove: function(event) { if (_.isDragging) { _.updateCoords(event); _.move(); } }, /* Methods *************************************/ updateElementCenter: function() { _.container.center.x = _.container.el.offsetLeft + _.container.radius; _.container.center.y = _.container.el.offsetTop + _.container.radius; }, updateCoords: function(e) { _.handle.x = e.clientX - _.container.center.x; _.handle.y = e.clientY - _.container.center.y; }, move: function() { _.degree.update(); if (_.degree.get() % opts.step === 0) { _.degree.el.innerHTML = _.degree.get(); _.container.el.setAttribute('data-degree', _.degree.get()); } _.handle.el.style['-webkit-transform'] = 'translate(' + _.handle.position('x') + 'px, ' + _.handle.position('y') + 'px)'; _.handle.el.style['-moz-transform'] = 'translate(' + _.handle.position('x') + 'px, ' + _.handle.position('y') + 'px)'; _.handle.el.style['-o-transform'] = 'translate(' + _.handle.position('x') + 'px, ' + _.handle.position('y') + 'px)'; _.handle.el.style.transform = 'translate(' + _.handle.position('x') + 'px, ' + _.handle.position('y') + 'px)'; opts.callback(_.container.el, _.degree.get()); } }; _.init(); /** * Picker API */ return { /** * Get picker value * @return {Number} */ getValue: _.degree.get, /** * Set value of picker * @param {Number} value */ setValue: _.degree.set };
};
var picker = new DegreePicker('.js-radius-picker');
Developer | Kasper Mikiewicz |
Username | Idered |
Uploaded | November 21, 2022 |
Rating | 4 |
Size | 4,307 Kb |
Views | 10,120 |
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 |
Comments thread | 3,601 Kb |
Pagination | 3,868 Kb |
Pure CSS3 Tags | 4,052 Kb |
Pure CSS read more toggle | 2,344 Kb |
Flat switch | 2,555 Kb |
Love button | 3,597 Kb |
2 CSS objects that will simplify your HTML structure | 4,136 Kb |
Dropdown menu | 3,350 Kb |
Animated underline | 2,593 Kb |
Confirmation button | 3,519 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 |
Display properties | Hamzaerbay | 1,886 Kb |
Perspective Origin Demo | Agelber | 3,614 Kb |
Spinners using Font Icons | Keyamoon | 3,007 Kb |
Weather App | Kw7oe | 3,162 Kb |
Angular Sandbox | Alexgurrola | 1,616 Kb |
A Pen by James Podles | Jpod | 2,656 Kb |
CSS Bot Confusion | Jpod | 3,456 Kb |
C.Rowe Button | Brownerd | 2,473 Kb |
Shopping cart | Andiio | 6,581 Kb |
Project MMetro beta | Atomicsong | 5,157 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!