forked from jquery/jquery-mousewheel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll.html
More file actions
51 lines (50 loc) · 2.22 KB
/
scroll.html
File metadata and controls
51 lines (50 loc) · 2.22 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
<!doctype html>
<html>
<head>
<title>Scroll Test</title>
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
#emulated, #native {
width: 40%;
height: 100%;
}
#emulated { float: left; overflow: hidden; }
#native { float: right; overflow: auto; }
</style>
<script>
( function() {
var src,
verMatch = /\bjquery=(\d\.\d\.\d(?:\.slim)?(?:\.min)?)/,
version = ( window.location.search.match( verMatch ) || [ "", "git" ] )[ 1 ];
if ( !version || version === "git" || version === "3.x-git" ) {
src = "https://releases.jquery.com/git/jquery-" + version + ".js"
} else {
src = "https://code.jquery.com/jquery-" + version + ".js";
}
document.write( "<script src=\"" + src + "\"><\/script>" );
} )();
</script>
<script src="../src/jquery.mousewheel.js"></script>
<script>
var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rhoncus nibh ac ultricies blandit. Nunc blandit blandit lobortis. Maecenas id dolor scelerisque, facilisis dolor eu, interdum urna. Nullam consectetur lectus quis mi interdum accumsan. Nulla malesuada est nec neque suscipit pulvinar. Vivamus sagittis, nunc a porttitor tempus, mi neque eleifend diam, nec porttitor metus dui a orci. Cras tempus lobortis nisl ut sagittis. Maecenas semper in magna mollis venenatis. Vestibulum fermentum tincidunt fringilla.";
$( function() {
for ( var i = 0; i < 30; i++ ) {
var html = "<p>" + i + " " + lorem + "</p>";
$( "#emulated" ).append( html );
$( "#native" ).append( html );
}
$( "#emulated" ).bind( "mousewheel", function( event ) {
event.preventDefault();
var scrollTop = this.scrollTop;
this.scrollTop = ( scrollTop + ( ( event.deltaY * event.deltaFactor ) * -1 ) );
// console.log( event.deltaY, event.deltaFactor,
// event.originalEvent.deltaMode, event.originalEvent.wheelDelta );
} );
} );
</script>
</head>
<body>
<div id="emulated"></div>
<div id="native"></div>
</body>
</html>