Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #505 from FormidableLabs/experiment/touch-events
Browse files Browse the repository at this point in the history
Experiment/touch events
  • Loading branch information
boygirl authored Aug 7, 2017
2 parents ee49992 + 146afcb commit 569eb15
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/containers/victory-brush-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const brushContainerMixin = (base) => class VictoryBrushContainer extends
onMouseDown: (evt, targetProps) => {
return BrushHelpers.onMouseDown(evt, targetProps);
},
onTouchStart: (evt, targetProps) => {
return BrushHelpers.onMouseDown(evt, targetProps);
},
onMouseMove: (evt, targetProps) => {
const mutations = BrushHelpers.onMouseMove(evt, targetProps);

Expand All @@ -52,11 +55,27 @@ export const brushContainerMixin = (base) => class VictoryBrushContainer extends

return undefined;
},
onTouchMove: (evt, targetProps) => {
const mutations = BrushHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) { // eslint-disable-line
this.mouseMoveMutationId = mutations.id; // eslint-disable-line
return mutations.mutations;
}

return undefined;
},
onMouseUp: (evt, targetProps) => {
return BrushHelpers.onMouseUp(evt, targetProps);
},
onTouchEnd: (evt, targetProps) => {
return BrushHelpers.onMouseUp(evt, targetProps);
},
onMouseLeave: (evt, targetProps) => {
return BrushHelpers.onMouseLeave(evt, targetProps);
},
onTouchCancel: (evt, targetProps) => {
return BrushHelpers.onMouseLeave(evt, targetProps);
}
}
}];
Expand Down
13 changes: 13 additions & 0 deletions src/components/containers/victory-cursor-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const cursorContainerMixin = (base) => class VictoryCursorContainer exten
onMouseLeave: () => {
return [];
},
onTouchCancel: () => {
return [];
},
onMouseMove: (evt, targetProps) => {
const mutations = CursorHelpers.onMouseMove(evt, targetProps);

Expand All @@ -52,6 +55,16 @@ export const cursorContainerMixin = (base) => class VictoryCursorContainer exten
return mutations.mutations;
}

return [];
},
onTouchMove: (evt, targetProps) => {
const mutations = CursorHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) { // eslint-disable-line
this.mouseMoveMutationId = mutations.id; // eslint-disable-line
return mutations.mutations;
}

return [];
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/containers/victory-selection-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const selectionContainerMixin = (base) => class VictorySelectionContainer
onMouseDown: (evt, targetProps) => {
return SelectionHelpers.onMouseDown(evt, targetProps);
},
onTouchStart: (evt, targetProps) => {
return SelectionHelpers.onMouseDown(evt, targetProps);
},
onMouseMove: (evt, targetProps) => {
const mutations = SelectionHelpers.onMouseMove(evt, targetProps);

Expand All @@ -40,8 +43,21 @@ export const selectionContainerMixin = (base) => class VictorySelectionContainer

return undefined;
},
onTouchMove: (evt, targetProps) => {
const mutations = SelectionHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) { // eslint-disable-line
this.mouseMoveMutationId = mutations.id; // eslint-disable-line
return mutations.mutations;
}

return undefined;
},
onMouseUp: (evt, targetProps) => {
return SelectionHelpers.onMouseUp(evt, targetProps);
},
onTouchEnd: (evt, targetProps) => {
return SelectionHelpers.onMouseUp(evt, targetProps);
}
}
}];
Expand Down
13 changes: 13 additions & 0 deletions src/components/containers/victory-voronoi-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const voronoiContainerMixin = (base) => class VictoryVoronoiContainer ext
onMouseLeave: (evt, targetProps) => {
return VoronoiHelpers.onMouseLeave(evt, targetProps);
},
onTouchCancel: (evt, targetProps) => {
return VoronoiHelpers.onMouseLeave(evt, targetProps);
},
onMouseMove: (evt, targetProps) => {
const mutations = VoronoiHelpers.onMouseMove(evt, targetProps);

Expand All @@ -37,6 +40,16 @@ export const voronoiContainerMixin = (base) => class VictoryVoronoiContainer ext
return mutations.mutations;
}

return undefined;
},
onTouchMove: (evt, targetProps) => {
const mutations = VoronoiHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) { // eslint-disable-line
this.mouseMoveMutationId = mutations.id; // eslint-disable-line
return mutations.mutations;
}

return undefined;
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/components/containers/victory-zoom-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,21 @@ export const zoomContainerMixin = (base) => class VictoryZoomContainer extends b
onMouseDown: (evt, targetProps) => {
return ZoomHelpers.onMouseDown(evt, targetProps);
},
onTouchStart: (evt, targetProps) => {
return ZoomHelpers.onMouseDown(evt, targetProps);
},
onMouseUp: (evt, targetProps) => {
return ZoomHelpers.onMouseUp(evt, targetProps);
},
onTouchEnd: (evt, targetProps) => {
return ZoomHelpers.onMouseUp(evt, targetProps);
},
onMouseLeave: (evt, targetProps) => {
return ZoomHelpers.onMouseLeave(evt, targetProps);
},
onTouchCancel: (evt, targetProps) => {
return ZoomHelpers.onMouseLeave(evt, targetProps);
},
onMouseMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params
evt.preventDefault();
const mutations = ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
Expand All @@ -61,6 +70,17 @@ export const zoomContainerMixin = (base) => class VictoryZoomContainer extends b

return undefined;
},
onTouchMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params
evt.preventDefault();
const mutations = ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);

if (mutations.id !== this.mouseMoveMutationId) { // eslint-disable-line
this.mouseMoveMutationId = mutations.id; // eslint-disable-line
return mutations.mutations;
}

return undefined;
},
onWheel: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params
if (targetProps.allowZoom) {
evt.preventDefault();
Expand Down

0 comments on commit 569eb15

Please sign in to comment.