Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
rough draft of trackX / trackY events
Browse files Browse the repository at this point in the history
lowercase event names

Add default touch-action no matter how many listeners have been added before
  • Loading branch information
dfreedm committed Aug 4, 2014
1 parent c9a0710 commit 37793c0
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@
exposes: [
'trackstart',
'track',
'trackx',
'tracky',
'trackend'
],
defaultActions: {
'track': 'none'
'track': 'none',
'trackx': 'pan-y',
'tracky': 'pan-x'
},
WIGGLE_THRESHOLD: 4,
clampDir: function(inDelta) {
Expand All @@ -139,33 +143,42 @@
var dd = this.calcPositionDelta(t.lastMoveEvent, inEvent);
if (dd.x) {
t.xDirection = this.clampDir(dd.x);
} else if (inType === 'trackx') {
return;
}
if (dd.y) {
t.yDirection = this.clampDir(dd.y);
} else if (inType === 'tracky') {
return;
}
var e = eventFactory.makeGestureEvent(inType, {
var gestureProto = {
bubbles: true,
cancelable: true,
dx: d.x,
dy: d.y,
ddx: dd.x,
ddy: dd.y,
x: inEvent.x,
y: inEvent.y,
clientX: inEvent.clientX,
clientY: inEvent.clientY,
pageX: inEvent.pageX,
pageY: inEvent.pageY,
screenX: inEvent.screenX,
screenY: inEvent.screenY,
xDirection: t.xDirection,
yDirection: t.yDirection,
trackInfo: t.trackInfo,
relatedTarget: inEvent.relatedTarget,
pointerType: inEvent.pointerType,
pointerId: inEvent.pointerId,
_source: 'track'
});
};
if (inType !== 'tracky') {
gestureProto.x = inEvent.x;
gestureProto.dx = d.x;
gestureProto.ddx = dd.x;
gestureProto.clientX = inEvent.clientX;
gestureProto.pageX = inEvent.pageX;
gestureProto.screenX = inEvent.screenX;
gestureProto.xDirection = t.xDirection;
}
if (inType !== 'trackx') {
gestureProto.dy = d.y;
gestureProto.ddy = dd.y;
gestureProto.y = inEvent.y;
gestureProto.clientY = inEvent.clientY;
gestureProto.pageY = inEvent.pageY;
gestureProto.screenY = inEvent.screenY;
gestureProto.yDirection = t.yDirection;
}
var e = eventFactory.makeGestureEvent(inType, gestureProto);
t.downTarget.dispatchEvent(e);
},
down: function(inEvent) {
Expand Down Expand Up @@ -193,10 +206,12 @@
p.tracking = true;
p.lastMoveEvent = p.downEvent;
this.fireTrack('trackstart', inEvent, p);
this.fireTrack('track', inEvent, p);
}
} else {
}
if (p.tracking) {
this.fireTrack('track', inEvent, p);
this.fireTrack('trackx', inEvent, p);
this.fireTrack('tracky', inEvent, p);
}
p.lastMoveEvent = inEvent;
}
Expand Down

0 comments on commit 37793c0

Please sign in to comment.