Skip to content

Commit

Permalink
Interaction: change update-pointer{-down,}
Browse files Browse the repository at this point in the history
Fired not only on down events.
  • Loading branch information
taye committed Apr 13, 2018
1 parent fc993a3 commit 86c22ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
20 changes: 10 additions & 10 deletions packages/core/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,20 @@ class Interaction {

this.pointerWasMoved = false;
}

this._signals.fire('update-pointer-down', {
pointer,
event,
eventTarget,
down,
pointerInfo,
pointerIndex,
interaction: this,
});
}

this._updateLatestPointer(pointer, event, eventTarget);

this._signals.fire('update-pointer', {
pointer,
event,
eventTarget,
down,
pointerInfo,
pointerIndex,
interaction: this,
});

return pointerIndex;
}

Expand Down
6 changes: 5 additions & 1 deletion packages/pointerEvents/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ function init (scope) {
interaction.holdTimers = []; // [{ duration, timeout }]
});

interactions.signals.on('update-pointer-down', function ({ interaction, pointerIndex }) {
interactions.signals.on('update-pointer', function ({ interaction, down, pointerIndex }) {
if (!down) {
return;
}

interaction.holdTimers[pointerIndex] = { duration: Infinity, timeout: null };
});

Expand Down
5 changes: 4 additions & 1 deletion packages/pointerEvents/tests/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test('pointerEvents.collectEventTargets', t => {
t.end();
});

test('pointerEvents Interaction update-pointer-down signal', t => {
test('pointerEvents Interaction update-pointer signal', t => {
const scope = helpers.mockScope();

interactions.init(scope);
Expand All @@ -127,6 +127,9 @@ test('pointerEvents Interaction update-pointer-down signal', t => {
const initialTimer = { duration: Infinity, timeout: null };
const event = {};

interaction.updatePointer(helpers.newPointer(0), event, null, false);
t.deepEqual(interaction.holdTimers, []);

interaction.updatePointer(helpers.newPointer(0), event, null, true);
t.deepEqual(interaction.holdTimers, [initialTimer]);

Expand Down

0 comments on commit 86c22ac

Please sign in to comment.