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
17 changes: 17 additions & 0 deletions src/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//////////////////////////////////////////////////////////////////////////////
/**
* Common object containing all action types that are provided by the GeoJS
* API.
*/
//////////////////////////////////////////////////////////////////////////////
var geo_action = {
momentum: 'geo_action_momentum',
pan: 'geo_action_pan',
rotate: 'geo_action_rotate',
select: 'geo_action_select',
unzoomselect: 'geo_action_unzoomselect',
zoom: 'geo_action_zoom',
zoomselect: 'geo_action_zoomselect'
};

module.exports = geo_action;
57 changes: 57 additions & 0 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,63 @@ geo_event.zoomselect = 'geo_zoomselect';
//////////////////////////////////////////////////////////////////////////////
geo_event.unzoomselect = 'geo_unzoomselect';

//////////////////////////////////////////////////////////////////////////////
/**
* Triggered when an action is initiated with mouse down
*
* @property {object} state The action state
* @property {geo.mouseState} mouse The mouse state
* @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?


//////////////////////////////////////////////////////////////////////////////
/**
* Triggered when an action is being processed during mouse movement.
*
* @property {object} state The action state
* @property {geo.mouseState} mouse The mouse state
* @property {object} event The triggering event
*/
//////////////////////////////////////////////////////////////////////////////
geo_event.actionmove = 'geo_actionmove';

//////////////////////////////////////////////////////////////////////////////
/**
* Triggered when an action is ended with a mouse up.
*
* @property {object} state The action state
* @property {geo.mouseState} mouse The mouse state
* @property {object} event The triggering event
*/
//////////////////////////////////////////////////////////////////////////////
geo_event.actionup = 'geo_actionup';

//////////////////////////////////////////////////////////////////////////////
/**
* Triggered when an action results in a selection.
*
* @property {object} state The action state
* @property {geo.mouseState} mouse The mouse state
* @property {object} event The triggering event
* @property {object} lowerLeft Lower left of selection in screen coordinates
* @property {object} upperRight Upper right of selection in screen coordinates
*/
//////////////////////////////////////////////////////////////////////////////
geo_event.actionselection = 'geo_actionselection';

//////////////////////////////////////////////////////////////////////////////
/**
* Triggered when an action is triggered with a mouse wheel event.
*
* @property {object} state The action state
* @property {geo.mouseState} mouse The mouse state
* @property {object} event The triggering event
*/
//////////////////////////////////////////////////////////////////////////////
geo_event.actionwheel = 'geo_actionwheel';

//////////////////////////////////////////////////////////////////////////////
/**
* Triggered before a map navigation animation begins. Set
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = $.extend({
featureLayer: require('./featureLayer'),
fetchQueue: require('./fetchQueue'),
fileReader: require('./fileReader'),
geo_action: require('./action'),
geomFeature: require('./geomFeature'),
graphFeature: require('./graphFeature'),
imageTile: require('./imageTile'),
Expand Down
Loading