-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage.html
More file actions
59 lines (46 loc) · 1.99 KB
/
Copy pathusage.html
File metadata and controls
59 lines (46 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hold</title>
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<!-- JQuery -->
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
<script src="js/jquery-event-holdrepeat.js"></script>
<script>
$(document).ready(function() {
const config = {
acceleration: 0.75,
accelerateAfter: 10,
maxIterationsPerHold: Infinity,
minRepeatInterval: 25,
repeatInterval: 150,
};
// Binding degli eventi custom
$('.btn-holdrepeat').on('holdrepeat',
config,
function(e) {
const a = $(this).data('action') == 'increase' ? 1 : -1;
const v = parseInt($('#counter').val());
$('#counter').val( a + v );
}
);
});
</script>
</head>
<body>
<div class="container mt-4 mb-4">
<div class="row">
<div class="col-sm-3">
<div class="input-group mb-3">
<button class="btn btn-outline-secondary btn-holdrepeat" type="button" data-action="decrease">-</button>
<input id="counter" type="text" class="form-control" placeholder="click or hold buttons" value="0">
<button class="btn btn-outline-secondary btn-holdrepeat" type="button" data-action="increase">+</button>
</div>
</div>
</div>
</div>
</body>
</html>