forked from ftlabs/fastclick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.html
More file actions
39 lines (38 loc) · 1.88 KB
/
input.html
File metadata and controls
39 lines (38 loc) · 1.88 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style type="text/css">
p, label { font-family: sans-serif; }
.test { text-align: center; }
input[type=text] { height: 3em; width: 10em; }
label { display: block; background: gray; line-height: 2em; display: inline-block; font-weight: bold; }
/* Disable certain interactions on touch devices */
body { -webkit-touch-callout: none; -webkit-text-size-adjust: none; -webkit-user-select: none; -webkit-highlight: none; -webkit-tap-highlight-color: rgba(0,0,0,0); }
</style>
<script type="application/javascript" src="../lib/fastclick.js"></script>
<script type="application/javascript">
window.addEventListener('load', function () {
FastClick.attach(document.body);
}, false);
</script>
</head>
<body>
<p>FastClick is instantiated on the body element, but the <code>input</code> element below will not receive fast clicks. Instead <code>focus()</code> will be called on the input element when <code>touchend</code> fires.</p>
<p>The keyboard will still appear after delay on iOS 4 or earlier, however.</p>
<div class="test">
<input type="text" id="tap-me" placeholder="Tap me">
</div>
<p>The same is true for the <code>select</code> element. It should open quickly on iOS > 4.</p>
<div class="test">
<select>
<option>Banana</option>
<option>Apple</option>
</select>
</div>
<p>The text below is a <code>label</code> for the text input element above. FastClick should automatically resolve the ID in the <code>for</code> attribute and trigger focus on the input element. This doesn't work on iOS 4, however (with or without FastClick).</p>
<label for="tap-me">I'm a label - tap me</label>
<p>Checkbox labels don't work on iOS 4, but with FastClick, they do!</p>
<input type="checkbox" id="check-me" /> <label for="check-me">I'm a label - tap me</label>
</body>
</html>