Click and Hold Button Animation

Size
2,433 Kb
Views
30,360

How do I make an click and hold button animation?

Experimenting with a button that will animate once clicked and hold for 1s. What is a click and hold button animation? How do you make a click and hold button animation? This script and codes were developed by Larry Geams Parangan on 27 November 2022, Sunday.

Click and Hold Button Animation Previews

Click and Hold Button Animation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Click and Hold Button Animation</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Click and Hold Button Animation</h1>
<button class="icon_close hold_trigger"> <span class="text">Hold Me!</span> <span class="spinner"></span>
</button> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Click and Hold Button Animation - Script Codes CSS Codes

body{ background: #F06060;
}
h1{ color: #fff; text-align: center; font-family: Arial; font-size: 50px; font-weight: normal;
}
button{ background: none repeat scroll 0 0 #CB4E4E; border-radius: 50%; box-shadow: 0 8px #AB3C3C; color: #FFFFFF; width: 150px; height: 150px; border: 0px; cursor: pointer; position: relative; font-size: 25px; margin: 5% auto; display: block; outline: none;
}
button:hover{ box-shadow: 0px 5px #AB3C3C; top: 2px;
}
button:active{ box-shadow: 0px 0px #AB3C3C; top: 5px;
}
.spinner{ position: absolute; left: 0; right: 0; top: 6%; moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border: 5px solid #fff;
border-left-color: transparent; border-right-color: transparent; border-top-color: transparent;
color: #52b700;
display: block;
font-size: 30px;
height: 135px;
line-height: 50px;
margin: 0 auto;
width: 135px;
-webkit-perspective: 300;
-moz-perspective: 300;
-ms-perspective: 300;
perspective: 300;
-webkit-transform: rotateY(0deg);
-webkit-transform-style: preserve-3d;
-moz-transform: rotateY(0deg);
-moz-transform-style: preserve-3d;
-ms-transform: rotateY(0deg);
-ms-transform-style: preserve-3d;
transform: rotateY(0deg);
transform-style: preserve-3d;
}
.active{ -webkit-animation: spin-cw 1s linear;
-moz-animation: spin-cw 1s linear;
animation: spin-cw 1s linear;
}
@-webkit-keyframes spin-cw { 0% { -webkit-transform:rotate(0deg); } 100% { -webkit-transform:rotate(360deg); }
}
@-moz-keyframes spin-cw { 0% { -moz-transform:rotate(0deg); } 100% { -moz-transform:rotate(360deg); }
}
@-o-keyframes spin-cw { 0% { -o-transform:rotate(0deg); } 100% { -o-transform:rotate(360deg); }
}
@keyframes spin-cw { 0% { transform:rotate(0deg); } 100% { transform:rotate(360deg); }
}

Click and Hold Button Animation - Script Codes JS Codes

var timeout_id = 0, hold_time = 1000, hold_trigger = $('.hold_trigger');
hold_trigger.mousedown(function() { timeout_id = setTimeout(menu_toggle, hold_time);
}).bind('mouseup mouseleave', function() { clearTimeout(timeout_id); $('.spinner').removeClass('active');
});
function menu_toggle() { $('.spinner').addClass('active');
}
Click and Hold Button Animation - Script Codes
Click and Hold Button Animation - Script Codes
Home Page Home
Developer Larry Geams Parangan
Username larrygeams
Uploaded November 27, 2022
Rating 3
Size 2,433 Kb
Views 30,360
Do you need developer help for Click and Hold Button Animation?

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!

Larry Geams Parangan (larrygeams) Script Codes
Create amazing marketing copy with AI!

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!