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

odd flags in Pointer subtypes #724

Closed
pixelzoom opened this issue Dec 18, 2017 · 2 comments
Closed

odd flags in Pointer subtypes #724

pixelzoom opened this issue Dec 18, 2017 · 2 comments
Assignees

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 18, 2017

The subtypes of Pointer each have an odd flag that effectively identifies their type:

// Mouse
isMouse: true

// Touch
isTouch: true

// Pen
isPen: true

isMouse and isTouch seem to be the preferred way of determining how an interactive object moves at the start of a drag cycle. For example, in equality-explorer ItemDragHandler:

var yOffset = ( event.pointer.isTouch ) ? -( 1.5 * this.item.icon.height ) : -( 0.5 * this.item.icon.height );

Since none of these flags are defined in Pointer, WebStorm (and other IDEs?) complain that these flags are unresolved variables. For the above example in WebStorm:

screenshot_437

Options:
• Live with the IDE complaint
• Define these flags in Pointer
• Get rid of the flags and use constructor comparison, e.g.: if ( event.pointer.constructor === Touch )

@jonathanolson
Copy link
Contributor

How about Mouse/Touch/Pen are cleaned up and we use pointer instanceof Mouse or similar statements?

@jonathanolson jonathanolson self-assigned this Dec 18, 2017
jonathanolson added a commit to phetsims/area-model-common that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/charges-and-fields that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/circuit-construction-kit-common that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/sun that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/equality-explorer that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/expression-exchange that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/joist that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/make-a-ten that referenced this issue Jan 17, 2018
jonathanolson added a commit to phetsims/molecule-shapes that referenced this issue Jan 17, 2018
@jonathanolson
Copy link
Contributor

Removed and refactored all usages to the suggested type above. Closing.

chrisklus pushed a commit to phetsims/counting-common that referenced this issue Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants