-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.html
109 lines (90 loc) · 4.29 KB
/
index.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Numans">
<link rel="stylesheet" href="style.css">
<title>unevent | Attach event handler functions with delay</title>
</head>
<body>
<h1 class="logo">unevent</h1>
<div>
<h2>Something about</h2>
<p>Attach an event handler function for one or more events to the selected elements if the event was <b>not</b> triggered for a given interval.</p>
<p>This is useful if you want to fire a callback only after a delay, like the resize event, or else.</p>
</div>
<div>
<h3>How to use</h3>
<p>It is quite simple!</p>
<p><span>1st</span> Include jQuery and the plugin:</p>
<pre><code><script src='jquery.js'></script>
<script src='jquery.unevent.js'></script></code></pre>
<p><span>2nd</span> Initialize <a href="https://github.com/yckart/jquery.unevent.js">unevent</a> like any other <code>on</code>-event handler, except that you can pass an extra parameter as a last:</p>
<pre><code>$(window).on('resize', function(e) {
// console.log(e.type + ' was 250ms not triggered');
}, 250);</code></pre>
<p><span>3rd</span> Trigger your <i>event</i>!</p>
</div>
<div id="example">
<h3>Example</h3>
<p>Move your mouse and wait 250ms...</p>
<pre><code>$('#example').on('mousemove', function(e) {
$('#box').html(e.type + ' was 250ms not triggered');
}, 250);
</code></pre>
<div id="box"></div>
</div>
<div>
<h3>Download</h3>
<p>
Get the <a href="https://raw.github.com/yckart/jquery.unevent.js/master/jquery.unevent.js">raw</a> script, download the complete <a href="https://github.com/yckart/jquery.unevent.js/zipball/master">package</a> or fork it on <a href="https://github.com/yckart/jquery.unevent.js/">GitHub</a>.
</p>
</div>
<div>
<h3>Support</h3>
<p>
<a href="http://twitter.com/yckart">@yckart</a> #unevent<br>
<a href="http://yckart.com/">http://yckart.com</a>
</p>
<h4>License</h4>
<tt>
<p>Copyright (c) 2013 Yannick Albert (<a href="http://yckart.com/">http://yckart.com/</a>)</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</p>
</tt>
</div>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="jquery.unevent.js"></script>
<script>
var $win = $(window),
$doc = $(document),
$logo = $('.logo'),
$box = $('#box');
$doc.on('mousemove', function(e) {
$box.html(e.type + ' is triggered');
});
$doc.on('mousemove', function(e) {
$box.html(e.type + ' was 250ms not triggered');
}, 250);
$win.on('resize', function(){
$logo.css({
fontSize: Math.max(Math.min($win.outerWidth() / (1 * 8), parseFloat(Number.POSITIVE_INFINITY)), parseFloat(Number.NEGATIVE_INFINITY))
});
}, 250).resize();
</script>
</body>
</html>