Skip to content

Instantly share code, notes, and snippets.

@airboss001
Created January 13, 2019 17:42
Show Gist options
  • Select an option

  • Save airboss001/9eb61f8840f2698f8c71b64b66c4d541 to your computer and use it in GitHub Desktop.

Select an option

Save airboss001/9eb61f8840f2698f8c71b64b66c4d541 to your computer and use it in GitHub Desktop.
triple click
.demo {
border: 1px solid lightgray;
padding: 1rem;
margin: 1rem;
text-align: center;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
.demo.dark {
background-color: lightgray;
}
<template>
<require from="./app.css"></require>
<div class="demo ${dark ? 'dark' : ''}" click.trigger="toggleBackground($event)">Triple click to change background</div>
</template>
export class App {
dark = false;
throttleClick = false;
lastTimeStamp = 0;
toggleBackground(event) {
if((event.timeStamp - this.lastTimeStamp) > 400) {
this.clickCounter = 1;
}
else {
this.clickCounter++;
}
this.lastTimeStamp = event.timeStamp;
if (this.throttleClick || this.clickCounter !== 3) return;
this.throttleClick = true;
setTimeout( () => {
this.throttleClick = false;
}, 5000);
this.dark = !this.dark;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment