Skip to content

Commit

Permalink
Fix issue with line height calculation when using older versions of j…
Browse files Browse the repository at this point in the history
…Query
  • Loading branch information
brandonaaron committed Feb 19, 2014
1 parent 1b6db9d commit 09bb82c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion jquery.mousewheel.js
Expand Up @@ -58,7 +58,11 @@
},

getLineHeight: function(elem) {
return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
var $parent = $(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
if (!$parent.length) {
$parent = $('body');
}
return parseInt($parent.css('fontSize'), 10);
},

getPageHeight: function(elem) {
Expand Down
7 changes: 6 additions & 1 deletion test/index.html
Expand Up @@ -113,7 +113,7 @@
$('#jqueryVersion').html($.fn.jquery);

var loghandle = function(event, delta) {
var o = '', id = event.currentTarget.id;
var o = '', id = event.currentTarget.id || event.currentTarget.nodeName;

o = '#' + id + ':';

Expand All @@ -137,6 +137,11 @@
log( o );
};

$(document)
.mousewheel(function(event, delta) {
loghandle(event, delta);
});

$('#test1')
.mousewheel(function(event, delta) {
loghandle(event, delta);
Expand Down

0 comments on commit 09bb82c

Please sign in to comment.