Custom Event Policing

Developer
Size
3,255 Kb
Views
6,072

How do I make an custom event policing?

Simple function to monitor events firing, and making sure they don't over fire due to user input (people clicking stuff way to fast). What is a custom event policing? How do you make a custom event policing? This script and codes were developed by Adam Grayson on 10 November 2022, Thursday.

Custom Event Policing Previews

Custom Event Policing - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Custom Event Policing</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="btn">Click Me</div>
<h1>Clicking Counter</h1>
<div class="output">0</div>
<h1>Window Resize Counter</h1>
<div class="output">0</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Custom Event Policing - Script Codes CSS Codes

@import url(https://fonts.googleapis.com/css?family=Lato:400,700);
html, body { background: #2682D5; font: 400 16px/16px "Lato", sans-serif;
}
h1 { margin-top: 50px; font-size: 20px; line-height: 24px; color: #FFFFFF; text-align: center;
}
.btn { width: 100px; padding: 12px 0; border: 1px solid #FFFFFF; color: #FFFFFF; border-radius: 4px; margin: 50px auto 0; text-align: center; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
}
.btn:hover { border: 1px solid #FFFFFF; color: #2682D5; background: #FFFFFF;
}
.btn:active { opacity: 0.7;
}
.output { width: 100px; padding: 12px 0; background: #FFFFFF; color: #777777; margin: 20px auto; text-align: center;
}

Custom Event Policing - Script Codes JS Codes

(function() { var clickCounter, eventPolice, increaseClickCounter, increaseResizeCounter, policing, resizeCounter; policing = false; clickCounter = 0; resizeCounter = 0; eventPolice = function(func, delayTime) { if (policing) { return; } policing = true; func(); setTimeout(function() { return policing = false; }, delayTime); }; increaseClickCounter = function() { clickCounter++; $('.output').eq(0).text(clickCounter); }; increaseResizeCounter = function() { resizeCounter++; $('.output').eq(1).text(resizeCounter); }; $('.btn').click(function() { eventPolice(increaseClickCounter, 800); }); $(window).resize(function() { eventPolice(increaseResizeCounter, 1000); });
}).call(this);
Custom Event Policing - Script Codes
Custom Event Policing - Script Codes
Home Page Home
Developer Adam Grayson
Username agrayson
Uploaded November 10, 2022
Rating 4
Size 3,255 Kb
Views 6,072
Do you need developer help for Custom Event Policing?

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!

Adam Grayson (agrayson) Script Codes
Create amazing sales emails 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!