first global commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# Mouse Wheel ChangeLog
|
||||
|
||||
# 3.0.4
|
||||
|
||||
* Fix IE issue
|
||||
|
||||
|
||||
# 3.0.3
|
||||
|
||||
* Added deltaX and deltaY for horizontal scrolling support (Thanks to Seamus Leahy)
|
||||
|
||||
|
||||
# 3.0.2
|
||||
|
||||
* Fixed delta being opposite value in latest Opera
|
||||
* No longer fix pageX, pageY for older mozilla browsers
|
||||
* Removed browser detection
|
||||
* Cleaned up the code
|
||||
|
||||
|
||||
# 3.0.1
|
||||
|
||||
* Bad release... creating a new release due to plugins.jquery.com issue :(
|
||||
|
||||
|
||||
# 3.0
|
||||
|
||||
* Uses new special events API in jQuery 1.2.2+
|
||||
* You can now treat "mousewheel" as a normal event and use .bind, .unbind and .trigger
|
||||
* Using jQuery.data API for expandos
|
||||
|
||||
|
||||
# 2.2
|
||||
|
||||
* Fixed pageX, pageY, clientX and clientY event properties for Mozilla based browsers
|
||||
|
||||
|
||||
# 2.1.1
|
||||
|
||||
* Updated to work with jQuery 1.1.3
|
||||
* Used one instead of bind to do unload event for clean up.
|
||||
|
||||
|
||||
# 2.1
|
||||
|
||||
* Fixed an issue with the unload handler
|
||||
|
||||
|
||||
# 2.0
|
||||
|
||||
* Major reduction in code size and complexity (internals have change a whole lot)
|
||||
|
||||
|
||||
# 1.0
|
||||
|
||||
* Fixed Opera issue
|
||||
* Fixed an issue with children elements that also have a mousewheel handler
|
||||
* Added ability to handle multiple handlers
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright 2010, Brandon Aaron (http://brandonaaron.net/)
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,24 @@
|
||||
# jQuery Mouse Wheel Plugin
|
||||
|
||||
A jQuery plugin that adds cross-browser mouse wheel support.
|
||||
|
||||
In order to use the plugin, simply bind the "mousewheel" event to an element. It also provides two helper methods called `mousewheel` and `unmousewheel` that act just like other event helper methods in jQuery. The event callback receives three extra arguments which are the normalized "deltas" of the mouse wheel.
|
||||
|
||||
Here is an example of using both the bind and helper method syntax.
|
||||
|
||||
// using bind
|
||||
$('#my_elem').bind('mousewheel', function(event, delta, deltaX, deltaY) {
|
||||
console.log(delta, deltaX, deltaY);
|
||||
});
|
||||
|
||||
// using the event helper
|
||||
$('#my_elem').mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
console.log(delta, deltaX, deltaY);
|
||||
});
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The expandable plugin is licensed under the MIT License (LICENSE.txt).
|
||||
|
||||
Copyright (c) 2010 [Brandon Aaron](http://brandonaaron.net)
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
||||
*
|
||||
* Version: 3.0.4
|
||||
*
|
||||
* Requires: 1.2.2+
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
var types = ['DOMMouseScroll', 'mousewheel'];
|
||||
|
||||
$.event.special.mousewheel = {
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.addEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.removeEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind("mousewheel", fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = "mousewheel";
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
|
||||
if ( event.detail ) { delta = -event.detail/3; }
|
||||
|
||||
// New school multidimensional scroll (touchpads) deltas
|
||||
deltaY = delta;
|
||||
|
||||
// Gecko
|
||||
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaY = 0;
|
||||
deltaX = -1*delta;
|
||||
}
|
||||
|
||||
// Webkit
|
||||
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
|
||||
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
return $.event.handle.apply(this, args);
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,318 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Testing mousewheel plugin</title>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
|
||||
<script type="text/javascript" src="../jquery.mousewheel.js"></script>
|
||||
|
||||
<style>
|
||||
#test1 {
|
||||
background-color: #000;
|
||||
width: 120px;
|
||||
height: 100px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#test2 {
|
||||
background-color: #333;
|
||||
width: 120px;
|
||||
height: 100px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#test3 {
|
||||
background-color: #666;
|
||||
width: 120px;
|
||||
height: 100px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#test4 {
|
||||
background-color: #000;
|
||||
width: 120px;
|
||||
height: 100px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#test5 {
|
||||
background-color: #333;
|
||||
padding: 5px;
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#test6 {
|
||||
background-color: #666;
|
||||
padding: 5px;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#test7 {
|
||||
background-color: #000;
|
||||
padding: 5px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
color: #fff;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#forceScroll {
|
||||
clear: both;
|
||||
height: 1000px;
|
||||
}
|
||||
|
||||
#logger {
|
||||
position: absolute;
|
||||
top: 395px;
|
||||
left: 12px;
|
||||
width: 460px;
|
||||
height: 290px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#logger p {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
padding: 2px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#logger p:nth-child(even) {
|
||||
background-color: #FFFFE8;
|
||||
}
|
||||
|
||||
#logger p:nth-child(10n) {
|
||||
border-bottom-color: #000;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#userAgent').html(navigator.userAgent);
|
||||
|
||||
|
||||
$('#test1')
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test1: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test1: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o );
|
||||
|
||||
log('pageX: ' + event.pageX + ' pageY: ' + event.pageY );
|
||||
});
|
||||
|
||||
$('#test2')
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test2: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test2: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o );
|
||||
return false; // prevent default
|
||||
});
|
||||
|
||||
$('#test3')
|
||||
.hover(function() { log('#test3: mouseover'); }, function() { log('#test3: mouseout'); })
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
log('#test3: I should not have been logged');
|
||||
})
|
||||
.unmousewheel();
|
||||
|
||||
var testRemoval = function(event, delta, deltaX, deltaY) {
|
||||
log('#test4: I should not have been logged');
|
||||
};
|
||||
|
||||
$('#test4')
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test4: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test4: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o );
|
||||
return false;
|
||||
})
|
||||
.mousewheel(testRemoval)
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test4: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test4: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o + ' from 2nd handler' );
|
||||
return false;
|
||||
})
|
||||
.unmousewheel(testRemoval);
|
||||
|
||||
$('#test5')
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test5: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test5: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o );
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('#test6')
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test6: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test6: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o );
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('#test7')
|
||||
.mousewheel(function(event, delta, deltaX, deltaY) {
|
||||
var o = '';
|
||||
if (delta > 0)
|
||||
o = '#test7: up ('+delta+')';
|
||||
else if (delta < 0)
|
||||
o = '#test7: down ('+delta+')';
|
||||
|
||||
if (deltaX > 0)
|
||||
o = o + ', east ('+deltaX+')';
|
||||
else if (deltaX < 0)
|
||||
o = o + ', west ('+deltaX+')';
|
||||
|
||||
if (deltaY > 0)
|
||||
o = o + ', north ('+deltaY+')';
|
||||
else if (deltaY < 0)
|
||||
o = o + ', south ('+deltaY+')';
|
||||
|
||||
if( o != '' )
|
||||
log( o );
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
function log(msg) {
|
||||
$('#logger').append('<p>'+msg+'</p>').scrollTop(999999);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="banner">jQuery mousewheel.js - Test</h1>
|
||||
<h2 id="userAgent"></h2>
|
||||
|
||||
<ul>
|
||||
<li><strong>Test1</strong> is just using the plain on mousewheel() with a function passed in and does not prevent default. (Also logs the value of pageX and pageY event properties.)</li>
|
||||
<li><strong>Test2</strong> should prevent the default action.</li>
|
||||
<li><strong>Test3</strong> should only log a mouseover and mouseout event. Testing unmousewheel().</li>
|
||||
<li><strong>Test4</strong> has two handlers.</li>
|
||||
<li><strong>Test5</strong> is like Test2 but has children. The children should not scroll until mousing over them.</li>
|
||||
<li><strong>Test6</strong> is like Test5 but should not scroll children or parents.</li>
|
||||
<li><strong>Test7</strong> is like Test6 but has no children. It will propagate the event and scroll test 6 as well.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<div id="test1"><p>Test1</p></div>
|
||||
<div id="test2"><p>Test2</p></div>
|
||||
<div id="test3"><p>Test3</p></div>
|
||||
<div id="test4"><p>Test4</p></div>
|
||||
<div id="test5">
|
||||
<p>Test5</p>
|
||||
<div id="test6">
|
||||
<p>Test6</p>
|
||||
<div id="test7"><p>Test7</p></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="logger"></div>
|
||||
|
||||
<div id="forceScroll"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user