Skip to content

Commit

Permalink
InteractEvent: make end dx/dy equal 0
Browse files Browse the repository at this point in the history
instead of the distance to the start coords
  • Loading branch information
taye committed Jan 10, 2016
1 parent a34f212 commit cbfaf00
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions src/InteractEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,16 @@ class InteractEvent {
}
}

signals.on('set-delta', function ({ iEvent, interaction, ending, starting, deltaSource }) {
if (starting) {
iEvent.dx = 0;
iEvent.dy = 0;
}
// end event dx, dy is difference between start and end points
else if (ending) {
if (deltaSource === 'client') {
iEvent.dx = iEvent.clientX - interaction.startCoords.client.x;
iEvent.dy = iEvent.clientY - interaction.startCoords.client.y;
}
else {
iEvent.dx = iEvent.pageX - interaction.startCoords.page.x;
iEvent.dy = iEvent.pageY - interaction.startCoords.page.y;
}
signals.on('set-delta', function ({ iEvent, interaction, starting, deltaSource }) {
const prevEvent = starting? iEvent : interaction.prevEvent;

if (deltaSource === 'client') {
iEvent.dx = iEvent.clientX - prevEvent.clientX;
iEvent.dy = iEvent.clientY - prevEvent.clientY;
}
else {
if (deltaSource === 'client') {
iEvent.dx = iEvent.clientX - interaction.prevEvent.clientX;
iEvent.dy = iEvent.clientY - interaction.prevEvent.clientY;
}
else {
iEvent.dx = iEvent.pageX - interaction.prevEvent.pageX;
iEvent.dy = iEvent.pageY - interaction.prevEvent.pageY;
}
iEvent.dx = iEvent.pageX - prevEvent.pageX;
iEvent.dy = iEvent.pageY - prevEvent.pageY;
}
});

Expand Down

0 comments on commit cbfaf00

Please sign in to comment.