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

Refactor how actions are specified and detected. #603

Merged
merged 10 commits into from
Aug 29, 2016

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Jul 27, 2016

This is primarily to make the code reusable in other modules. This results in some improvements:

  • Modifier keys can be ignored. For instance, ctrl-left drag defaults to rotation, shift must not be pressed, but the state of alt and meta is irrelevant.
  • You could add an action that requires two mouse buttons.

This is a breaking change.

This is primarily to make the code reusable in other modules.  This results in some improvements:
* Modifier keys can be ignored.  For instance, ctrl-left drag defaults to rotation, shift must not be pressed, but the state of alt and meta is irrelevant.
* You could add an action that requires two mouse buttons.

This is a breaking change.
* shift, ctrl, alt, meta
*/
actions: [{
action: 'pan',
Copy link
Member

Choose a reason for hiding this comment

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

@manthey should we define action and event values as some keys at one single place? for e.g. (or some other way)

user_actions = {
pan: "pan",
zoom: "zoom"
}

and then we can have:

action: user_actions.pan

Thoughts?

@aashish24
Copy link
Member

Mostly looks good to me, has few suggestions.

@codecov-io
Copy link

codecov-io commented Aug 10, 2016

Current coverage is 81.80% (diff: 98.31%)

Merging #603 into master will increase coverage by 0.10%

@@             master       #603   diff @@
==========================================
  Files            82         83     +1   
  Lines          7492       7563    +71   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           6121       6187    +66   
- Misses         1371       1376     +5   
  Partials          0          0          

Powered by Codecov. Last update 0a6efce...136e2d5

@aashish24
Copy link
Member

@manthey are you planning to update this branch with suggestions as we discussed?

@manthey
Copy link
Contributor Author

manthey commented Aug 18, 2016

@aashish24 Yes, soon.

Trigger more events to allow other interactors more fine-grained control.  For actions with a selection rectangle, use a flag in the action definition rather than a test against the action name.  Return the action record from the eventMatch function.  Add convenience functions for adding and removing actions.
@aashish24
Copy link
Member

thanks @manthey it's looking very good, will post my final comments by tomorrow morning.

* @property {object} event The triggering event
*/
//////////////////////////////////////////////////////////////////////////////
geo_event.actiondown = 'geo_actiondown';
Copy link
Member

Choose a reason for hiding this comment

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

@manthey nitpick: we use camelcase style for other event for example

geo_event.worldChanged = 'geo_worldChanged';

Should we change geo_event.actiondown to geo_event.actionDown? (and similarly for others too?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We haven't been consistent: geo_event.brushend = geo_brushend, for instance. I can change the actions to camel case or not as you prefer. I'd be tempted to make the events consistent in casing, but that would be a breaking change for not much benefit.

Copy link
Member

Choose a reason for hiding this comment

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

We haven't been consistent: geo_event.brushend = geo_brushend, for instance. I can change the actions to camel case or not as you prefer. I'd be tempted to make the events consistent in casing, but that would be a breaking change for not much benefit.

I think it would be nice to have the consistency IMO but we can file the bug for now and break it when we release 1.0. I would be okay with that. Thoughts?

The term 'event' was overused.
@aashish24
Copy link
Member

other than my new comments, the branch LGTM 👍

As part of this, there doesn't need to be a one-to-one correspondence between actions and events.  Moreover, selection rectangle-based actions can trigger any event.
@manthey
Copy link
Contributor Author

manthey commented Aug 26, 2016

@aashish24 I've added actions as a set of defined constants and updated the tests.

rotate: 'geo_action_rotate',
select: 'geo_action_select',
unzoomselect: 'geo_action_unzoomselect',
zoom: 'zoom',
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is intentional (meaning not "geo_zoom")?

@aashish24
Copy link
Member

Looking much better @manthey just had one question on "zoom"

@manthey
Copy link
Contributor Author

manthey commented Aug 26, 2016

@aashish24 Updated.

@aashish24
Copy link
Member

LGTM 👍 thanks

@manthey manthey merged commit 12a68a2 into master Aug 29, 2016
@manthey manthey deleted the refactor-interactor-actions branch August 29, 2016 12:01
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

Successfully merging this pull request may close these issues.

3 participants