<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="header">iScroll</div>
<div id="wrapper">
<div id="scroller">
<ul>
<li id="ret"></li>
<li><a href="http://m.nuomi.com/">Pretty row 1</a></li>
<li>Pretty row 2</li>
<li data-url="http://m.nuomi.com/">Pretty row 3</li>
<li>Pretty row 4</li>
<li>Pretty row 5</li>
<li>Pretty row 6</li>
<li>Pretty row 7</li>
<li>Pretty row 8</li>
<li>Pretty row 9</li>
<li>Pretty row 10</li>
<li>Pretty row 11</li>
<li>Pretty row 12</li>
<li>Pretty row 13</li>
<li>Pretty row 14</li>
<li>Pretty row 15</li>
<li>Pretty row 16</li>
<li>Pretty row 17</li>
<li>Pretty row 18</li>
<li>Pretty row 19</li>
<li>Pretty row 20</li>
</ul>
</div>
</div>
<div id="footer"></div>
</body>
</html>
<style>
* {
box-sizing: border-box;
box-sizing: border-box;
box-sizing: border-box;
}
html {
touch-action: none;
}
body,ul,li {
padding: 0;
margin: 0;
border: 0;
}
body {
font-size: 12px;
font-family: ubuntu, helvetica, arial;
overflow: hidden; /* this is important to prevent the whole page to bounce */
}
#header {
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 45px;
line-height: 45px;
background: #CD235C;
padding: 0;
color: #eee;
font-size: 20px;
text-align: center;
font-weight: bold;
}
#footer {
position: absolute;
z-index: 2;
bottom: 0;
left: 0;
width: 100%;
height: 48px;
background: #444;
padding: 0;
border-top: 1px solid #444;
}
#wrapper {
position: absolute;
z-index: 1;
top: 45px;
bottom: 48px;
left: 0;
width: 100%;
background: #ccc;
/*overflow: hidden;*/
overflow: auto;
}
#scroller {
position: absolute;
z-index: 1;
tap-highlight-color: rgba(0,0,0,0);
width: 100%;
transform: translateZ(0);
transform: translateZ(0);
transform: translateZ(0);
transform: translateZ(0);
transform: translateZ(0);
touch-callout: none;
user-select: none;
user-select: none;
user-select: none;
user-select: none;
text-size-adjust: none;
text-size-adjust: none;
text-size-adjust: none;
text-size-adjust: none;
text-size-adjust: none;
}
#scroller ul {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
text-align: left;
}
#scroller li {
padding: 10px;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
background-color: #fafafa;
font-size: 14px;
}
</style>
var ret = document.querySelector('#ret');
document.querySelector('#wrapper').addEventListener('touchstart', function (e) {
// 阻止 click 触发
// e.preventDefault();
ret.textContent = ' -> touchstart';
}, false)
document.querySelector('#wrapper').addEventListener('touchmove', function (e) {
// 不会阻止 click 触发, only prevent scroll and pinch-zoom
// e.preventDefault();
ret.textContent = ret.textContent + ' -> touchmove';
}, false);
document.querySelector('#wrapper').addEventListener('touchend', function (e) {
// 阻止 click 触发
// e.preventDefault();
ret.textContent = ret.textContent + ' -> touchend';
}, false);
document.querySelector('#wrapper').addEventListener('click', function (e) {
// e.preventDefault();
ret.textContent = ret.textContent + ' -> click';
}, false);
Output
300px
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |