Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use offsetX & offsetY instead of x & y to get relative positions #445

Merged
merged 2 commits into from
Mar 22, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/react/deckgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class DeckGL extends React.Component {

// Route events to layers
_onClick(event) {
const {x, y} = event;
const {event: {offsetX: x = 0, offsetY: y = 0} = {}} = event;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Since we are changing this to fix an issue should we add a line of comment why we are using offsetX and offsetY?
  • About the default values: Is this just a sanity check or is there are reason for the defaults? I.e. when is offsetX and offsetY undefined? Do we want to send a 0,0 event in those cases? Or drop the event? Or pass along the undefined so that app can check? Maybe add another comment line about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a sanity check.

I agree it makes more sense to drop the event if either event.event is falsy (luma.gl addEvent fails, shouldn't be) or offsetX offsetY are falsy (browser fails, again shouldn't be according to the spec); it's also heavy and requires changes on existing apps if we surface the error message via the picked object.

will just drop the event if sanity check fails.

const selectedInfos = this.layerManager.pickLayer({x, y, mode: 'click'});
if (selectedInfos.length) {
const firstInfo = selectedInfos.find(info => info.index >= 0);
Expand All @@ -130,7 +130,7 @@ export default class DeckGL extends React.Component {

// Route events to layers
_onMouseMove(event) {
const {x, y} = event;
const {event: {offsetX: x = 0, offsetY: y = 0} = {}} = event;
const selectedInfos = this.layerManager.pickLayer({x, y, mode: 'hover'});
if (selectedInfos.length) {
const firstInfo = selectedInfos.find(info => info.index >= 0);
Expand Down