Slow Click Button
How do I make an slow click button?
Sometimes you need a button to take a second before it kicks in. Like say a self-destruct button or something.. What is a slow click button? How do you make a slow click button? This script and codes were developed by Matthew Chase on 25 July 2022, Monday.
Slow Click Button - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Slow Click Button</title> <link rel='stylesheet prefetch' href='http://elrumordelaluz.github.io/csshake/css/csshake.min.css'>
<link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Audiowide'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="button-wrapper"> <button class="slow-click shake-constant">Self Destruct</button>
</div>
<p class="thanks"> Shake CSS effect from <a href="http://elrumordelaluz.github.io/csshake/" target="_blank">http://elrumordelaluz.github.io/csshake/</a>
</p> <script src="js/index.js"></script>
</body>
</html>
Slow Click Button - Script Codes CSS Codes
html { box-sizing: border-box;
}
*, *:before, *:after { box-sizing: inherit;
}
body{ background-color: #202; text-align: center; padding-top: 40px;
}
.thanks{ color: white; font-family: sans-serif; font-size: 11px; margin: 2em 0;
}
.thanks a{ color: yellow;
}
.button-wrapper{ transition: all 0.25s ease; display: inline-block; padding: 20px; background-image: linear-gradient(135deg, yellow 0, yellow 10%, #101 10%, #101 20%, yellow 20%, yellow 30%, #101 30%, #101 40%, yellow 40%, yellow 50%, #101 50%, #101 60%, yellow 60%, yellow 70%, #101 70%, #101 80%, yellow 80%, yellow 90%, #101 90%, #101 100%); border: 3px solid #101; border-radius: 20px; box-shadow: 0 0 20px 6px rgba(255, 0, 0, 0.25);
}
button.slow-click{ font-family: Audiowide; color: #900; background-color: black; border: 2px solid red; font-size: 20px; display: inline-block; padding: 0.3333em 1em; font-size: 200%; position: relative; outline: none; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; font-weight: bold; border-radius: 15px; text-transform: uppercase; box-shadow: inset 0 0 8px 8px rgba(255, 255, 128, 0.1);
}
Slow Click Button - Script Codes JS Codes
(function(){ var button, clickTimeout, frameInterval, holdTime; var clickDuration = 5000; var clickStart = null; function onDocumentReady(){ button = document.querySelector('.slow-click'); button.addEventListener('click', onButtonClick); button.addEventListener('click', onButtonSlowClick); button.addEventListener('mousedown', onMouseDown); button.addEventListener('mouseup', onMouseUp); button.addEventListener('mouseleave', onMouseLeave); } function onMouseLeave(e){ cancelSlowClick(e); } function onMouseUp(e){ cancelSlowClick(e); } function onMouseDown(e){ beginSlowClick(e); } function beginSlowClick(e){ clickStart = Date.now(); clearTimeout(clickTimeout); clickTimeout = setTimeout(function(){ completeSlowClick(e); }, clickDuration); clearInterval(frameInterval); frameInterval = setInterval(function(){ continueSlowClick(e); }, 1000 / 60); } function continueSlowClick(e){ var timeElapsed = Date.now() - clickStart; var interval = timeElapsed / clickDuration; var percentage = (interval * 100).toFixed(4) + '%'; var gradient = [ 'rgba(255, 0, 0, 0.25)', 'rgba(255, 0, 0, 0.25) ' + percentage, 'transparent ' + percentage, ]; var shakeClass = ""; if(interval > 0.05){ shakeClass = "shake shake-little"; } if(interval > 0.33){ shakeClass = "shake"; } if(interval > 0.75){ shakeClass = "shake shake-hard"; } e.target.className = "slow-click shake-constant " + shakeClass; e.target.style.backgroundImage = 'linear-gradient(to right, '+gradient.join(', ')+' )'; } function completeSlowClick(e){ continueSlowClick(e); var click = new MouseEvent('click', { 'view': window, 'bubbles': true, 'cancelable': true }); click.slowClick = true; e.target.dispatchEvent(click); finishSlowClick(e); } function cancelSlowClick(e){ finishSlowClick(e); } function finishSlowClick(e){ e.target.style.background = null; e.target.className = "slow-click shake-constant"; clearTimeout(clickTimeout); clearInterval(frameInterval); } function onButtonClick(e){ if(e.slowClick !== true){ e.preventDefault(); e.stopImmediatePropagation(); return false; } } function onButtonSlowClick(e){ window.location.href = 'http://i.imgur.com/RTf93hM.gif'; } document.addEventListener('DOMContentLoaded', onDocumentReady);
})();
Developer | Matthew Chase |
Username | antishow |
Uploaded | July 25, 2022 |
Rating | 3.5 |
Size | 3,035 Kb |
Views | 149,776 |
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 |
Flex-Grow Proportions | 3,276 Kb |
THREE.js PointCloud | 3,960 Kb |
THREE.js Starter Kit - Disco Fireflies | 2,387 Kb |
Grassssss tastes bad. | 2,275 Kb |
Sort Floated UL into columns | 1,950 Kb |
Mouse Effect - SVG Firework under click | 2,908 Kb |
Curvy Slider | 2,557 Kb |
THREE.js Starter Kit - Basic Sta--Fireflies | 2,376 Kb |
Simple Snowflakes | 2,650 Kb |
AnimationController | 3,390 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 Jim Savage | Madebyjam | 2,418 Kb |
Sequence.js - Sliding Horizontal Parallax | Maheshc | 4,537 Kb |
Brown by pure CSS, no image, no javascript | Aaronchuo | 2,652 Kb |
Coburg Banks SVG Logo | Mjtweaver | 3,875 Kb |
Box-sizing | Elad2412 | 1,572 Kb |
JS Beispiel getElementsByClassName 3 | HSZG-Frontend-Kurs | 1,988 Kb |
SnappySnippet Test | Elmsoftware | 8,385 Kb |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
CSS3 Fullscreen Background Slideshow | Leetech | 3,435 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!