Skip to content

Commit

Permalink
clean up requestPick method
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Mar 26, 2019
1 parent 5aaabc5 commit 9a46e10
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions modules/core/src/lib/deck.js
Expand Up @@ -441,14 +441,14 @@ export default class Deck {
return views;
}

_requestPick(options, immediate) {
_requestPick({event, callback, mode, immediate}) {
const {_pickRequest} = this;
if (options.event.type === 'pointerleave') {
if (event.type === 'pointerleave') {
_pickRequest.x = -1;
_pickRequest.y = -1;
_pickRequest.radius = 0;
} else {
const pos = options.event.offsetCenter;
const pos = event.offsetCenter;
// Do not trigger callbacks when click/hover position is invalid. Doing so will cause a
// assertion error when attempting to unproject the position.
if (!pos) {
Expand All @@ -459,9 +459,9 @@ export default class Deck {
_pickRequest.radius = this.props.pickingRadius;
}

_pickRequest.callback = options.callback;
_pickRequest.event = options.event;
_pickRequest.mode = options.mode;
_pickRequest.callback = callback;
_pickRequest.event = event;
_pickRequest.mode = mode;

if (immediate) {
this._pickAndCallback();
Expand Down Expand Up @@ -704,14 +704,12 @@ export default class Deck {
}

_onPointerDown(event) {
this._requestPick(
{
callback: this.props.onHover,
event,
mode: 'hover'
},
true
);
this._requestPick({
callback: this.props.onHover,
event,
mode: 'hover',
immediate: true
});
}

_onPointerMove(event) {
Expand Down

0 comments on commit 9a46e10

Please sign in to comment.