Vertical drag to change
How do I make an vertical drag to change?
What is a vertical drag to change? How do you make a vertical drag to change? This script and codes were developed by Marco Dell'Anna on 14 June 2022, Tuesday.
Vertical drag to change - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Vertical drag to change</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p>Click and ...drag</p>
<div class="joystick__dummy joystick__dummy--up"></div>
<div class="joystick__dummy joystick__dummy--down"></div>
<div id="joystick" data-dumping="3" class="joystick"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Vertical drag to change - Script Codes CSS Codes
html { width: 100%; height: 100%; cursor: crosshair; background: #121212;
}
p { font-family: "Montserrat"; font-size: 12px; color: #FFF;
}
.joystick__dummy { position: relative; transition: opacity 0.4s ease-out, transform 0.4s ease-out; width: 10px; height: 10px; background: transparent; border: 1px solid #fefefe; border-radius: 10px; margin: 0 0 0 -6px; opacity: 0; transform: scale(0);
}
.joystick__dummy--show { opacity: 1; transform: scale(1);
}
.joystick { position: absolute; width: 0; height: 0;
}
.joystick:after { transition: all 0.5s ease-in-out; position: absolute; content: ""; width: 150px; height: 150px; border: 1px solid #fefefe; border-radius: 150px; top: -75px; left: -75px; opacity: 0;
}
.joystick:before { transition: all 0.2s ease-in; content: ""; position: absolute; width: 50px; height: 50px; background: transparent; border: 1px solid #fefefe; border-radius: 50px; top: -26px; left: -26px;
}
.joystick--down:before { width: 10px; height: 10px; top: -6px; left: -6px; background: #fefefe;
}
.joystick--down:after { transition: all 0.2s ease-in; width: 10px; height: 10px; top: -6px; left: -6px; opacity: 1;
}
Vertical drag to change - Script Codes JS Codes
(function() { var Joystick, follow; Joystick = (function() { Joystick.prototype.status = "up"; Joystick.prototype.startCoordinate = { x: 0, y: 0 }; Joystick.prototype.defaults = { dumping: 1, disable: false, coordiantes_to_follow: { x: 0, y: 0 }, offset: { x: 0, y: 0 }, onChange: function(coordinates) {} }; Joystick.prototype.setCoordinates = function(data) { return this.options.coordiantes_to_follow = data; }; Joystick.prototype.follow = function() { var coordinates, dumping, offset, valueX, xd, yd; if (!this.element.data("dumping")) { dumping = this.element.data("dumping") || this.options.dumping; this.element.data("dumping", dumping); } else { dumping = this.element.data("dumping"); } offset = this.element.offset(); xd = this.options.offset.x + this.options.coordiantes_to_follow.x - offset.left; yd = this.options.offset.y + this.options.coordiantes_to_follow.y - offset.top; if (this.status === "up") { valueX = offset.left + xd / dumping; } else { valueX = this.startCoordinate.x; } if (this.status === "down") { if (offset.top >= (this.startCoordinate.y + 100) || offset.top <= (this.startCoordinate.y - 100 + 12)) { this.destroyDummy(); this.status = "up"; } } coordinates = { x: valueX, y: offset.top + yd / dumping }; this.element.css({ "left": coordinates.x, "top": coordinates.y }); this.options.onChange(coordinates); if (!this.disable) { return requestAnimationFrame((function(_this) { return function() { return _this.follow(); }; })(this)); } }; Joystick.prototype.createDummy = function() { this.dummy1 = $("<div class=\"joystick__dummy joystick__dummy--up\" />"); this.dummy2 = $("<div class=\"joystick__dummy joystick__dummy--down\" />"); $("body").append(this.dummy1).append(this.dummy2); $(this.dummy1).css({ "position": "absolute", "left": this.startCoordinate.x, "top": this.startCoordinate.y + 100 }).addClass("joystick__dummy--show"); return $(this.dummy2).css({ "position": "absolute", "left": this.startCoordinate.x, "top": this.startCoordinate.y - 100 }).addClass("joystick__dummy--show"); }; Joystick.prototype.destroyDummy = function() { $(this.dummy1).removeClass("joystick__dummy--show"); return $(this.dummy2).removeClass("joystick__dummy--show"); }; Joystick.prototype.addBehaviour = function() { $(document).on("mousedown", (function(_this) { return function(e) { e.preventDefault(); e.stopPropagation(); _this.status = "down"; _this.startCoordinate = { "x": e.pageX, "y": e.pageY }; $(_this.element).addClass("joystick--down"); return _this.createDummy(); }; })(this)); return $(document).on("mouseup", (function(_this) { return function(e) { _this.status = "up"; $(_this.element).removeClass("joystick--down"); return _this.destroyDummy(); }; })(this)); }; function Joystick(element, options) { this.options = $.extend({}, this.defaults, options); this.element = $(element); this.disable = this.options.disable; this.addBehaviour(); if (!this.disable) { this.follow(); } } return Joystick; })(); follow = new Joystick("#joystick", { offset: { x: 0, y: 0 } }); $(window).on("mousemove.follow", function(e) { return follow.setCoordinates({ x: e.pageX, y: e.pageY }); });
}).call(this);
Developer | Marco Dell'Anna |
Username | plasm |
Uploaded | June 14, 2022 |
Rating | 3 |
Size | 4,488 Kb |
Views | 56,672 |
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 |
BLOOD - Deviation of microcosm | 4,615 Kb |
Antigravity FLOW | 6,295 Kb |
MAGNETO | 5,266 Kb |
DISTANCES | 6,073 Kb |
Connections | 5,681 Kb |
Follow | 3,175 Kb |
LOOK-AT-dark | 6,032 Kb |
MICROCOSM | 4,612 Kb |
Icosahedron | 12,471 Kb |
Mosaica 3D css | 4,986 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 |
A Pen by Dalton Liu | Liudalton | 12,437 Kb |
Flexbox Test | Icutpeople | 2,486 Kb |
Airbnb Homepage | SindhujaD | 2,480 Kb |
Sort the Knowlege | Eprouver | 3,915 Kb |
Vue Transition | Chenming142 | 4,561 Kb |
Z-index demo | Kblh | 1,534 Kb |
Drifting Clouds | Benedikte | 2,247 Kb |
404 Page | Saransh | 2,666 Kb |
Under construction | GhostRider | 1,642 Kb |
Cool Page Split Effect | Anthonyadamski | 6,128 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!