Skip to content

Minor improvements #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
"indent": 4,
"jquery" : true,
"latedef": true,
"maxerr": 50,
"noarg": true,
"node": true,
"noempty": true,
"plusplus": false,
"quotmark": "single",
"regexp": true,
"strict": false,
"trailing": true,
"unused": true,
Expand Down
20 changes: 10 additions & 10 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

## 3.1.6

* Deprecating delta, deltaX, and deltaY event handler arguments
* Update actual event object with normalized deltaX and deltaY values (event.deltaX, event.deltaY)
* Add deltaFactor to the event object (event.deltaFactor)
* Handle > 0 but < 1 deltas better
* Do not fire the event if deltaX and deltaY are 0
* Better handle different devices that give different lowestDelta values
* Add $.event.special.mousewheel.version
* Deprecating `delta`, `deltaX`, and `deltaY` event handler arguments
* Update actual event object with normalized `deltaX `and `deltaY` values (`event.deltaX`, `event.deltaY`)
* Add `deltaFactor` to the event object (`event.deltaFactor`)
* Handle `> 0` but `< 1` deltas better
* Do not fire the event if `deltaX` and `deltaY` are `0`
* Better handle different devices that give different `lowestDelta` values
* Add `$.event.special.mousewheel.version`
* Some clean up

## 3.1.5

* Bad release because I did not update the new $.event.special.mousewheel.version
* Bad release because I did not update the new `$.event.special.mousewheel.version`

## 3.1.4

* Always set the deltaY
* Add back in the deltaX and deltaY support for older Firefox versions
* Always set the `deltaY`
* Add back in the `deltaX` and `deltaY` support for older Firefox versions

## 3.1.3

Expand Down
22 changes: 11 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ module.exports = function(grunt) {
}
},
connect: {
server: {
options: {
hostname: '*',
keepalive: true,
middleware: function(connect, options) {
return [
connect.static(options.base),
connect.directory(options.base)
];
}
server: {
options: {
hostname: '*',
keepalive: true,
middleware: function(connect, options) {
return [
connect.static(options.base),
connect.directory(options.base)
];
}
}
}
}
}
});

Expand Down
10 changes: 5 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "3.1.6",
"main": "./jquery.mousewheel.js",
"ignore": [
".*",
"*.txt",
"*.markdown",
"*.json",
"test",
"Gruntfile.js"
"*.markdown",
"*.txt",
".*",
"Gruntfile.js",
"test"
],
"dependencies": {
"jquery": ">=1.2.2"
Expand Down
12 changes: 6 additions & 6 deletions jquery.mousewheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@

// New school wheel delta (wheel event)
if ( 'deltaY' in orgEvent ) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ( 'deltaX' in orgEvent ) {
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
}

// No change actually happened, no reason to go any further
Expand All @@ -107,7 +107,7 @@
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;
lowestDelta = absDelta;
}

// Get a whole, normalized value for the deltas
Expand All @@ -134,7 +134,7 @@
}

function nullLowestDelta() {
lowestDelta = null;
lowestDelta = null;
}

}));
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "3.1.6",
"author": "Brandon Aaron <brandon.aaron@gmail.com> (http://brandonaaron.net/)",
"description": "A jQuery plugin that adds cross-browser mouse wheel support.",
"license": "MIT",
"homepage": "https://github.com/brandonaaron/jquery-mousewheel",
"main": "./jquery.mousewheel.js",
"repository": {
"type": "git",
Expand All @@ -20,17 +22,16 @@
"plugin",
"browser"
],
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/brandonaaron/jquery-mousewheel/master/LICENSE.txt"
}
"files": [
"ChangeLog.md",
"jquery.mousewheel.js",
"README.md"
],
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-uglify": "~0.2.4",
"grunt-contrib-connect": "~0.5.0"
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.7"
},
"directories": {
"test": "test"
Expand Down
39 changes: 21 additions & 18 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@
<title>Testing mousewheel plugin</title>

<script>
(function(){
var verMatch = /v=([\w\.]+)/.exec( location.search ),
version = verMatch && verMatch[1], src;
if ( version ) {
src = 'code.jquery.com/jquery-' + version;
} else {
src = 'code.jquery.com/jquery-git';
}
document.write( '<script src="http://' + src + '.js"><\/script>' );
(function() {
var verMatch = /v=([\w\.]+)/.exec(location.search),
version = verMatch && verMatch[1],
src;
if (version)
src = 'code.jquery.com/jquery-' + version;
else
src = 'code.jquery.com/jquery-git';
document.write('<script src="http://' + src + '.js"><\/script>');
})();
</script>
<script src="../jquery.mousewheel.js"></script>

<style>
html {
font: 13px Arial, sans-serif;
}

#stage {
position: relative;
zoom: 1;
}

#test1 {
background-color: #000;
width: 120px;
Expand Down Expand Up @@ -98,15 +103,13 @@
}

#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;
background-color: #ffffe8;
}

#logger p:nth-child(10n) {
Expand Down Expand Up @@ -157,12 +160,12 @@

$('#test3')
.hover(function() { log('#test3: mouseover'); }, function() { log('#test3: mouseout'); })
.mousewheel(function(event, delta, deltaX, deltaY) {
.mousewheel(function() {
log('#test3: I should not have been logged');
})
.unmousewheel();

var testRemoval = function(event, delta, deltaX, deltaY) {
var testRemoval = function() {
log('#test4: I should not have been logged');
};

Expand Down Expand Up @@ -199,8 +202,8 @@
});

function log(msg) {
$('#logger').append('<p>'+msg+'<\/p>')[0].scrollTop = 999999;
};
$('#logger').append('<p>' + msg + '<\/p>')[0].scrollTop = 999999;
}
});
</script>
</head>
Expand All @@ -209,9 +212,9 @@ <h1 id="banner">jQuery mousewheel.js Test with jQuery <span id="jqueryVersion"><
<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>Test1</strong> is just using the plain on <code>mousewheel()</code> with a function passed in and does not prevent default. (Also logs the value of <code>pageX</code> and <code>pageY</code> 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>Test3</strong> should only log a <code>mouseover</code> and <code>mouseout</code> event. Testing <code>unmousewheel()</code>.</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>
Expand Down