Skip to content

Commit

Permalink
Fixes issue 15, delta values throwing out spurious values.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephband committed Oct 28, 2013
1 parent d27c9a6 commit 82ea750
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ <h3>Find me on...</h3>
e.deltaX === e.pageX - pageX,
e.deltaY === e.pageY - pageY);

if ((e.deltaX === e.distX - distX) +
(e.deltaY === e.distY - distY) +
(e.deltaX === e.pageX - pageX) +
(e.deltaY === e.pageY - pageY) !== 4) {
console.log('X', distX, e.distX, pageX, e.pageX, e.deltaX);
console.log('Y', distY, e.distY, pageY, e.pageY, e.deltaY);
}

distY = e.distY;
distX = e.distX;
pageX = e.pageX;
Expand Down
34 changes: 20 additions & 14 deletions js/jquery.event.move.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@

function Timer(fn){
var callback = fn,
active = false,
running = false;
active = false,
running = false;

function trigger(time) {
if (active){
Expand Down Expand Up @@ -341,10 +341,11 @@
// Handlers that control what happens following a movestart

function activeMousemove(e) {
var event = e.data.event,
timer = e.data.timer;
var timer = e.data.timer;

updateEvent(event, e, e.timeStamp, timer);
e.data.touch = e;
e.data.timeStamp = e.timeStamp;
timer.kick();
}

function activeMouseend(e) {
Expand Down Expand Up @@ -378,7 +379,9 @@
e.preventDefault();

event.targetTouches = e.targetTouches;
updateEvent(event, touch, e.timeStamp, timer);
e.data.touch = touch;
e.data.timeStamp = e.timeStamp;
timer.kick();
}

function activeTouchend(e) {
Expand Down Expand Up @@ -416,8 +419,6 @@
event.velocityY = 0.3 * event.velocityY + 0.7 * event.deltaY / time;
event.pageX = touch.pageX;
event.pageY = touch.pageY;

timer.kick();
}

function endEvent(event, timer, fn) {
Expand Down Expand Up @@ -486,13 +487,18 @@
remove: removeMethod,

_default: function(e) {
var template, data;
var event, data;

// If no move events were bound to any ancestors of this
// target, high tail it out of here.
if (!e._handled()) { return; }

template = {
function update(time) {
updateEvent(event, data.touch, data.timeStamp);
trigger(e.target, event);
}

event = {
target: e.target,
startX: e.startX,
startY: e.startY,
Expand All @@ -511,10 +517,10 @@
};

data = {
event: template,
timer: new Timer(function(time){
trigger(e.target, template);
})
event: event,
timer: new Timer(update),
touch: undefined,
timeStamp: undefined
};

if (e.identifier === undefined) {
Expand Down

0 comments on commit 82ea750

Please sign in to comment.