Fixed mousewheel scroll distance, some JSLint complaints, corrected minification
parent
571fe4c707
commit
00b1badbcd
|
@ -21,5 +21,5 @@
|
|||
### Notes:
|
||||
|
||||
If you aren't using the minified version, be sure to include
|
||||
`lib/jquery.mousewheel.min.js` in your page if you require mousewheel
|
||||
`lib/jquery.mousewheel.js` in your page if you require mousewheel
|
||||
scrolling via fixed columns.
|
|
@ -50,7 +50,7 @@
|
|||
var $self = $(this), // reference the jQuery version of the current DOM element
|
||||
self = this; // reference to the actual DOM element
|
||||
|
||||
if ( helpers._isTable($self) ) {
|
||||
if (helpers._isTable($self)) {
|
||||
methods.setup.apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
$.isFunction(settings.create) && settings.create.call(this);
|
||||
} else {
|
||||
|
@ -62,7 +62,7 @@
|
|||
/*
|
||||
* Setup table structure for fixed headers and optional footer
|
||||
*/
|
||||
setup: function( options ) {
|
||||
setup: function (options) {
|
||||
var $self = $(this),
|
||||
self = this,
|
||||
$thead = $self.find('thead'),
|
||||
|
@ -80,7 +80,7 @@
|
|||
settings.scrollbarOffset = helpers._getScrollbarWidth();
|
||||
settings.themeClassName = settings.themeClass;
|
||||
|
||||
if ( settings.width.search('%') > -1 ) {
|
||||
if (settings.width.search('%') > -1) {
|
||||
var widthMinusScrollbar = $self.parent().width() - settings.scrollbarOffset;
|
||||
} else {
|
||||
var widthMinusScrollbar = settings.width - settings.scrollbarOffset;
|
||||
|
@ -91,14 +91,14 @@
|
|||
});
|
||||
|
||||
|
||||
if ( !$self.closest('.fht-table-wrapper').length ) {
|
||||
if (!$self.closest('.fht-table-wrapper').length) {
|
||||
$self.addClass('fht-table');
|
||||
$self.wrap('<div class="fht-table-wrapper"></div>');
|
||||
}
|
||||
|
||||
$wrapper = $self.closest('.fht-table-wrapper');
|
||||
|
||||
if ( settings.fixedColumns > 0 && $wrapper.find('.fht-fixed-column').length == 0 ) {
|
||||
if (settings.fixedColumns > 0 && $wrapper.find('.fht-fixed-column').length == 0) {
|
||||
$self.wrap('<div class="fht-fixed-body"></div>');
|
||||
|
||||
var $fixedColumns = $('<div class="fht-fixed-column"></div>').prependTo($wrapper),
|
||||
|
@ -111,7 +111,7 @@
|
|||
})
|
||||
.addClass(settings.themeClassName);
|
||||
|
||||
if ( !$self.hasClass('fht-table-init') ) {
|
||||
if (!$self.hasClass('fht-table-init')) {
|
||||
|
||||
$self.wrap('<div class="fht-tbody"></div>');
|
||||
|
||||
|
@ -120,10 +120,10 @@
|
|||
|
||||
var tableProps = helpers._getTableProps($self);
|
||||
|
||||
helpers._setupClone( $divBody, tableProps.tbody );
|
||||
helpers._setupClone($divBody, tableProps.tbody);
|
||||
|
||||
if ( !$self.hasClass('fht-table-init') ) {
|
||||
if ( settings.fixedColumns > 0 ) {
|
||||
if (!$self.hasClass('fht-table-init')) {
|
||||
if (settings.fixedColumns > 0) {
|
||||
$divHead = $('<div class="fht-thead"><table class="fht-table"></table></div>').prependTo($fixedBody);
|
||||
} else {
|
||||
$divHead = $('<div class="fht-thead"><table class="fht-table"></table></div>').prependTo($wrapper);
|
||||
|
@ -134,7 +134,7 @@
|
|||
$divHead = $wrapper.find('div.fht-thead');
|
||||
}
|
||||
|
||||
helpers._setupClone( $divHead, tableProps.thead );
|
||||
helpers._setupClone($divHead, tableProps.thead);
|
||||
|
||||
$self.css({
|
||||
'margin-top': -$divHead.outerHeight(true)
|
||||
|
@ -144,11 +144,11 @@
|
|||
* Check for footer
|
||||
* Setup footer if present
|
||||
*/
|
||||
if ( settings.footer == true ) {
|
||||
if (settings.footer == true) {
|
||||
|
||||
helpers._setupTableFooter( $self, self, tableProps );
|
||||
helpers._setupTableFooter($self, self, tableProps);
|
||||
|
||||
if ( !$tfoot.length ) {
|
||||
if (!$tfoot.length) {
|
||||
$tfoot = $wrapper.find('div.fht-tfoot table');
|
||||
}
|
||||
|
||||
|
@ -163,19 +163,19 @@
|
|||
|
||||
$self.addClass('fht-table-init');
|
||||
|
||||
if ( typeof(settings.altClass) !== 'undefined' ) {
|
||||
methods.altRows.apply( self );
|
||||
if (typeof(settings.altClass) !== 'undefined') {
|
||||
methods.altRows.apply(self);
|
||||
}
|
||||
|
||||
if ( settings.fixedColumns > 0 ) {
|
||||
helpers._setupFixedColumn( $self, self, tableProps );
|
||||
if (settings.fixedColumns > 0) {
|
||||
helpers._setupFixedColumn($self, self, tableProps);
|
||||
}
|
||||
|
||||
if ( !settings.autoShow ) {
|
||||
if (!settings.autoShow) {
|
||||
$wrapper.hide();
|
||||
}
|
||||
|
||||
helpers._bindScroll( $divBody, tableProps );
|
||||
helpers._bindScroll($divBody, tableProps);
|
||||
|
||||
return self;
|
||||
},
|
||||
|
@ -184,20 +184,19 @@
|
|||
* Resize the table
|
||||
* Incomplete - not implemented yet
|
||||
*/
|
||||
resize: function( options ) {
|
||||
resize: function(options) {
|
||||
var $self = $(this),
|
||||
self = this;
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/*
|
||||
* Add CSS class to alternating rows
|
||||
*/
|
||||
altRows: function( arg1 ) {
|
||||
var $self = $(this),
|
||||
self = this,
|
||||
altClass = ( typeof(arg1) !== 'undefined' ) ? arg1 : settings.altClass;
|
||||
altRows: function(arg1) {
|
||||
var $self = $(this),
|
||||
self = this,
|
||||
altClass = (typeof(arg1) !== 'undefined') ? arg1 : settings.altClass;
|
||||
|
||||
$self.closest('.fht-table-wrapper')
|
||||
.find('tbody tr:odd:not(:hidden)')
|
||||
|
@ -207,13 +206,13 @@
|
|||
/*
|
||||
* Show a hidden fixedHeaderTable table
|
||||
*/
|
||||
show: function( arg1, arg2, arg3 ) {
|
||||
show: function(arg1, arg2, arg3) {
|
||||
var $self = $(this),
|
||||
self = this,
|
||||
$wrapper = $self.closest('.fht-table-wrapper');
|
||||
|
||||
// User provided show duration without a specific effect
|
||||
if ( typeof(arg1) !== 'undefined' && typeof(arg1) === 'number' ) {
|
||||
if (typeof(arg1) !== 'undefined' && typeof(arg1) === 'number') {
|
||||
|
||||
$wrapper.show(arg1, function() {
|
||||
$.isFunction(arg2) && arg2.call(this);
|
||||
|
@ -221,8 +220,8 @@
|
|||
|
||||
return self;
|
||||
|
||||
} else if ( typeof(arg1) !== 'undefined' && typeof(arg1) === 'string'
|
||||
&& typeof(arg2) !== 'undefined' && typeof(arg2) === 'number' ) {
|
||||
} else if (typeof(arg1) !== 'undefined' && typeof(arg1) === 'string'
|
||||
&& typeof(arg2) !== 'undefined' && typeof(arg2) === 'number') {
|
||||
// User provided show duration with an effect
|
||||
|
||||
$wrapper.show(arg1, arg2, function() {
|
||||
|
@ -243,20 +242,20 @@
|
|||
/*
|
||||
* Hide a fixedHeaderTable table
|
||||
*/
|
||||
hide: function( arg1, arg2, arg3 ) {
|
||||
hide: function(arg1, arg2, arg3) {
|
||||
var $self = $(this),
|
||||
self = this,
|
||||
$wrapper = $self.closest('.fht-table-wrapper');
|
||||
|
||||
// User provided show duration without a specific effect
|
||||
if ( typeof(arg1) !== 'undefined' && typeof(arg1) === 'number' ) {
|
||||
if (typeof(arg1) !== 'undefined' && typeof(arg1) === 'number') {
|
||||
$wrapper.hide(arg1, function() {
|
||||
$.isFunction(arg3) && arg3.call(this);
|
||||
});
|
||||
|
||||
return self;
|
||||
} else if ( typeof(arg1) !== 'undefined' && typeof(arg1) === 'string'
|
||||
&& typeof(arg2) !== 'undefined' && typeof(arg2) === 'number' ) {
|
||||
} else if (typeof(arg1) !== 'undefined' && typeof(arg1) === 'string'
|
||||
&& typeof(arg2) !== 'undefined' && typeof(arg2) === 'number') {
|
||||
|
||||
$wrapper.hide(arg1, arg2, function() {
|
||||
$.isFunction(arg3) && arg3.call(this);
|
||||
|
@ -304,13 +303,13 @@
|
|||
* return boolean
|
||||
* True if a thead and tbody exist.
|
||||
*/
|
||||
_isTable: function( $obj ) {
|
||||
_isTable: function($obj) {
|
||||
var $self = $obj,
|
||||
hasTable = $self.is('table'),
|
||||
hasThead = $self.find('thead').length > 0,
|
||||
hasTbody = $self.find('tbody').length > 0;
|
||||
|
||||
if ( hasTable && hasThead && hasTbody ) {
|
||||
if (hasTable && hasThead && hasTbody) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -322,14 +321,14 @@
|
|||
* return void
|
||||
* bind scroll event
|
||||
*/
|
||||
_bindScroll: function( $obj, tableProps ) {
|
||||
_bindScroll: function($obj, tableProps) {
|
||||
var $self = $obj,
|
||||
$wrapper = $self.closest('.fht-table-wrapper'),
|
||||
$thead = $self.siblings('.fht-thead'),
|
||||
$tfoot = $self.siblings('.fht-tfoot');
|
||||
|
||||
$self.bind('scroll', function() {
|
||||
if ( settings.fixedColumns > 0 ) {
|
||||
if (settings.fixedColumns > 0) {
|
||||
var $fixedColumns = $wrapper.find('.fht-fixed-column');
|
||||
|
||||
$fixedColumns.find('.fht-tbody table')
|
||||
|
@ -343,7 +342,7 @@
|
|||
'margin-left': -this.scrollLeft
|
||||
});
|
||||
|
||||
if ( settings.cloneHeadToFoot ) {
|
||||
if (settings.cloneHeadToFoot) {
|
||||
$tfoot.find('table')
|
||||
.css({
|
||||
'margin-left': -this.scrollLeft
|
||||
|
@ -355,8 +354,8 @@
|
|||
/*
|
||||
* return void
|
||||
*/
|
||||
_fixHeightWithCss: function ( $obj, tableProps ) {
|
||||
if ( settings.includePadding ) {
|
||||
_fixHeightWithCss: function ($obj, tableProps) {
|
||||
if (settings.includePadding) {
|
||||
$obj.css({
|
||||
'height': $obj.height() + tableProps.border
|
||||
});
|
||||
|
@ -370,8 +369,8 @@
|
|||
/*
|
||||
* return void
|
||||
*/
|
||||
_fixWidthWithCss: function( $obj, tableProps, width ) {
|
||||
if ( settings.includePadding ) {
|
||||
_fixWidthWithCss: function($obj, tableProps, width) {
|
||||
if (settings.includePadding) {
|
||||
$obj.each(function(index) {
|
||||
$(this).css({
|
||||
'width': width == undefined ? $(this).width() + tableProps.border : width + tableProps.border
|
||||
|
@ -390,7 +389,7 @@
|
|||
/*
|
||||
* return void
|
||||
*/
|
||||
_setupFixedColumn: function ( $obj, obj, tableProps ) {
|
||||
_setupFixedColumn: function ($obj, obj, tableProps) {
|
||||
var $self = $obj,
|
||||
self = obj,
|
||||
$wrapper = $self.closest('.fht-table-wrapper'),
|
||||
|
@ -413,8 +412,8 @@
|
|||
});
|
||||
|
||||
// Fix cell heights
|
||||
helpers._fixHeightWithCss( $firstThChildren, tableProps );
|
||||
helpers._fixWidthWithCss( $firstThChildren, tableProps );
|
||||
helpers._fixHeightWithCss($firstThChildren, tableProps);
|
||||
helpers._fixWidthWithCss($firstThChildren, tableProps);
|
||||
|
||||
var tdWidths = [];
|
||||
$firstThChildren.each(function(index) {
|
||||
|
@ -423,9 +422,9 @@
|
|||
|
||||
firstTdChildrenSelector = 'tbody tr td:not(:nth-child(n+' + (settings.fixedColumns + 1) + '))';
|
||||
$firstTdChildren = $fixedBody.find(firstTdChildrenSelector)
|
||||
.each( function(index) {
|
||||
helpers._fixHeightWithCss( $(this), tableProps);
|
||||
helpers._fixWidthWithCss( $(this), tableProps, tdWidths[index % settings.fixedColumns] );
|
||||
.each(function(index) {
|
||||
helpers._fixHeightWithCss($(this), tableProps);
|
||||
helpers._fixWidthWithCss($(this), tableProps, tdWidths[index % settings.fixedColumns] );
|
||||
});
|
||||
|
||||
// clone header
|
||||
|
@ -444,7 +443,7 @@
|
|||
if (index % settings.fixedColumns == 0) {
|
||||
$newRow = $('<tr></tr>').appendTo($tbody.find('tbody'));
|
||||
|
||||
if ( settings.altClass && $(this).parent().hasClass(settings.altClass) ) {
|
||||
if (settings.altClass && $(this).parent().hasClass(settings.altClass)) {
|
||||
$newRow.addClass(settings.altClass);
|
||||
}
|
||||
}
|
||||
|
@ -462,13 +461,14 @@
|
|||
|
||||
// bind mousewheel events
|
||||
var maxTop = $fixedColumn.find('.fht-tbody .fht-table').height() - $fixedColumn.find('.fht-tbody').height();
|
||||
console.log(maxTop);
|
||||
$fixedColumn.find('.fht-table').bind('mousewheel', function(event, delta) {
|
||||
var top = parseInt($(this).css('marginTop'), 10) + (delta > 0 ? 40 : -40);
|
||||
$fixedColumn.find('.fht-table').bind('mousewheel', function(event, delta, deltaX, deltaY) {
|
||||
if (deltaY == 0) return;
|
||||
var top = parseInt($(this).css('marginTop'), 10) + (deltaY > 0 ? 120 : -120);
|
||||
if (top > 0) top = 0;
|
||||
if (top < -maxTop) top = -maxTop;
|
||||
$(this).css('marginTop', top);
|
||||
$fixedBody.find('.fht-tbody').scrollTop(-top);
|
||||
$fixedBody.find('.fht-tbody').scrollTop(-top).scroll();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
@ -478,10 +478,10 @@
|
|||
});
|
||||
|
||||
// setup clone footer with fixed column
|
||||
if ( settings.footer == true || settings.cloneHeadToFoot == true ) {
|
||||
if (settings.footer == true || settings.cloneHeadToFoot == true) {
|
||||
var $firstTdFootChild = $fixedBody.find('.fht-tfoot thead tr th:lt(' + settings.fixedColumns + ')');
|
||||
|
||||
helpers._fixHeightWithCss( $firstTdFootChild, tableProps );
|
||||
helpers._fixHeightWithCss($firstTdFootChild, tableProps);
|
||||
$tfoot.appendTo($fixedColumn)
|
||||
.find('tr')
|
||||
.append($firstTdFootChild.clone());
|
||||
|
@ -494,7 +494,7 @@
|
|||
/*
|
||||
* return void
|
||||
*/
|
||||
_setupTableFooter: function ( $obj, obj, tableProps ) {
|
||||
_setupTableFooter: function ($obj, obj, tableProps) {
|
||||
|
||||
var $self = $obj,
|
||||
self = obj,
|
||||
|
@ -502,8 +502,8 @@
|
|||
$tfoot = $self.find('tfoot'),
|
||||
$divFoot = $wrapper.find('div.fht-tfoot');
|
||||
|
||||
if ( !$divFoot.length ) {
|
||||
if ( settings.fixedColumns > 0 ) {
|
||||
if (!$divFoot.length) {
|
||||
if (settings.fixedColumns > 0) {
|
||||
$divFoot = $('<div class="fht-tfoot"><table class="fht-table"></table></div>').appendTo($wrapper.find('.fht-fixed-body'));
|
||||
} else {
|
||||
$divFoot = $('<div class="fht-tfoot"><table class="fht-table"></table></div>').appendTo($wrapper);
|
||||
|
@ -529,7 +529,7 @@
|
|||
'margin-top': -tableProps.border
|
||||
});
|
||||
|
||||
helpers._setupClone( $divFoot, tableProps.tfoot );
|
||||
helpers._setupClone($divFoot, tableProps.tfoot);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -541,7 +541,7 @@
|
|||
* Widths of each thead cell and tbody cell for the first rows.
|
||||
* Used in fixing widths for the fixed header and optional footer.
|
||||
*/
|
||||
_getTableProps: function( $obj ) {
|
||||
_getTableProps: function($obj) {
|
||||
var tableProp = {
|
||||
thead: {},
|
||||
tbody: {},
|
||||
|
@ -550,11 +550,11 @@
|
|||
},
|
||||
borderCollapse = 1;
|
||||
|
||||
if ( settings.borderCollapse == true ) {
|
||||
if (settings.borderCollapse == true) {
|
||||
borderCollapse = 2;
|
||||
}
|
||||
|
||||
tableProp.border = ( $obj.find('th:first-child').outerWidth() - $obj.find('th:first-child').innerWidth() ) / borderCollapse;
|
||||
tableProp.border = ($obj.find('th:first-child').outerWidth() - $obj.find('th:first-child').innerWidth()) / borderCollapse;
|
||||
|
||||
$obj.find('thead tr:first-child th').each(function(index) {
|
||||
tableProp.thead[index] = $(this).width() + tableProp.border;
|
||||
|
@ -575,17 +575,17 @@
|
|||
* return void
|
||||
* Fix widths of each cell in the first row of obj.
|
||||
*/
|
||||
_setupClone: function( $obj, cellArray ) {
|
||||
_setupClone: function($obj, cellArray) {
|
||||
var $self = $obj,
|
||||
selector = ( $self.find('thead').length ) ?
|
||||
selector = ($self.find('thead').length) ?
|
||||
'thead th' :
|
||||
( $self.find('tfoot').length ) ?
|
||||
($self.find('tfoot').length) ?
|
||||
'tfoot td' :
|
||||
'tbody td',
|
||||
$cell;
|
||||
|
||||
$self.find(selector).each(function(index) {
|
||||
$cell = ( $(this).find('div.fht-cell').length ) ? $(this).find('div.fht-cell') : $('<div class="fht-cell"></div>').appendTo($(this));
|
||||
$cell = ($(this).find('div.fht-cell').length) ? $(this).find('div.fht-cell') : $('<div class="fht-cell"></div>').appendTo($(this));
|
||||
|
||||
$cell.css({
|
||||
'width': parseInt(cellArray[index])
|
||||
|
@ -595,8 +595,8 @@
|
|||
* Fixed Header and Footer should extend the full width
|
||||
* to align with the scrollbar of the body
|
||||
*/
|
||||
if ( !$(this).closest('.fht-tbody').length && $(this).is(':last-child') && !$(this).closest('.fht-fixed-column').length ) {
|
||||
var padding = ( ( $(this).innerWidth() - $(this).width() ) / 2 ) + settings.scrollbarOffset;
|
||||
if (!$(this).closest('.fht-tbody').length && $(this).is(':last-child') && !$(this).closest('.fht-fixed-column').length) {
|
||||
var padding = (($(this).innerWidth() - $(this).width()) / 2) + settings.scrollbarOffset;
|
||||
$(this).css({
|
||||
'padding-right': padding + 'px'
|
||||
});
|
||||
|
@ -625,7 +625,7 @@
|
|||
newHeight = $obj.find('td').height();
|
||||
$obj.remove();
|
||||
|
||||
if ( defaultHeight != newHeight ) {
|
||||
if (defaultHeight != newHeight) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -640,8 +640,8 @@
|
|||
_getScrollbarWidth: function() {
|
||||
var scrollbarWidth = 0;
|
||||
|
||||
if ( !scrollbarWidth ) {
|
||||
if ( $.browser.msie ) {
|
||||
if (!scrollbarWidth) {
|
||||
if ($.browser.msie) {
|
||||
var $textarea1 = $('<textarea cols="10" rows="2"></textarea>')
|
||||
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body'),
|
||||
$textarea2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>')
|
||||
|
@ -665,13 +665,13 @@
|
|||
|
||||
|
||||
// if a method as the given argument exists
|
||||
if ( methods[method] ) {
|
||||
if (methods[method]) {
|
||||
|
||||
// call the respective method
|
||||
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
|
||||
// if an object is given as method OR nothing is given as argument
|
||||
} else if ( typeof method === 'object' || !method ) {
|
||||
} else if (typeof method === 'object' || !method) {
|
||||
|
||||
// call the initialization method
|
||||
return methods.init.apply(this, arguments);
|
||||
|
@ -680,7 +680,7 @@
|
|||
} else {
|
||||
|
||||
// trigger an error
|
||||
$.error( 'Method "' + method + '" does not exist in fixedHeaderTable plugin!');
|
||||
$.error('Method "' + method + '" does not exist in fixedHeaderTable plugin!');
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,90 @@
|
|||
/*! 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
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
var wheelDeltaScaleFactor = 1;
|
||||
if (jQuery.browser.msie || (jQuery.browser.webkit && !(/chrome/.test(userAgent)))) {
|
||||
wheelDeltaScaleFactor = 40;
|
||||
}
|
||||
|
||||
if (orgEvent.wheelDeltaY !== undefined) {
|
||||
deltaY = orgEvent.wheelDeltaY / 120 / wheelDeltaScaleFactor;
|
||||
}
|
||||
if (orgEvent.wheelDeltaX !== undefined) {
|
||||
deltaX = -1*orgEvent.wheelDeltaX / 120 / wheelDeltaScaleFactor;
|
||||
}
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
return $.event.handle.apply(this, args);
|
||||
}
|
||||
|
||||
})(jQuery);
|
|
@ -1,12 +0,0 @@
|
|||
/* 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(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(i){var g=i||window.event,f=[].slice.call(arguments,1),j=0,h=true,e=0,d=0;i=c.event.fix(g);i.type="mousewheel";if(i.wheelDelta){j=i.wheelDelta/120}if(i.detail){j=-i.detail/3}d=j;if(g.axis!==undefined&&g.axis===g.HORIZONTAL_AXIS){d=0;e=-1*j}if(g.wheelDeltaY!==undefined){d=g.wheelDeltaY/120}if(g.wheelDeltaX!==undefined){e=-1*g.wheelDeltaX/120}f.unshift(i,j,e,d);return c.event.handle.apply(this,f)}})(jQuery);
|
Loading…
Reference in New Issue