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

fix create container mixin #561

Merged
merged 1 commit into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions src/components/containers/brush-helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Selection } from "victory-core";
import { assign, throttle, isFunction, isEqual, defaults, mapValues } from "lodash";
import { attachId } from "../../helpers/event-handlers";

const Helpers = {
withinBounds(point, bounds, padding) {
Expand Down Expand Up @@ -265,7 +264,7 @@ export default {
onMouseUp: Helpers.onMouseUp.bind(Helpers),
onMouseLeave: Helpers.onMouseLeave.bind(Helpers),
onMouseMove: throttle(
attachId(Helpers.onMouseMove.bind(Helpers)),
Helpers.onMouseMove.bind(Helpers),
16, // eslint-disable-line no-magic-numbers
{ leading: true, trailing: false }
)
Expand Down
3 changes: 1 addition & 2 deletions src/components/containers/cursor-helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Selection } from "victory-core";
import { throttle, isFunction } from "lodash";
import { attachId } from "../../helpers/event-handlers";
import BrushHelpers from "./brush-helpers";

const CursorHelpers = {
Expand Down Expand Up @@ -44,7 +43,7 @@ const CursorHelpers = {

export default {
onMouseMove: throttle(
attachId(CursorHelpers.onMouseMove.bind(CursorHelpers)),
CursorHelpers.onMouseMove.bind(CursorHelpers),
32, // eslint-disable-line no-magic-numbers
{ leading: true, trailing: false })
};
3 changes: 1 addition & 2 deletions src/components/containers/selection-helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Selection, Data, Helpers } from "victory-core";
import { assign, defaults, throttle, isFunction } from "lodash";
import React from "react";
import { attachId } from "../../helpers/event-handlers";

const SelectionHelpers = {
getDatasets(props) {
Expand Down Expand Up @@ -156,7 +155,7 @@ export default {
onMouseDown: SelectionHelpers.onMouseDown.bind(SelectionHelpers),
onMouseUp: SelectionHelpers.onMouseUp.bind(SelectionHelpers),
onMouseMove: throttle(
attachId(SelectionHelpers.onMouseMove.bind(SelectionHelpers)),
SelectionHelpers.onMouseMove.bind(SelectionHelpers),
16, // eslint-disable-line no-magic-numbers
{ leading: true, trailing: false })
};
22 changes: 4 additions & 18 deletions src/components/containers/victory-brush-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,11 @@ export const brushContainerMixin = (base) => class VictoryBrushContainer extends
onTouchStart: (evt, targetProps) => {
return BrushHelpers.onMouseDown(evt, targetProps);
},
onMouseMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = BrushHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
onMouseMove: (evt, targetProps) => {
return BrushHelpers.onMouseMove(evt, targetProps);
},
onTouchMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = BrushHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
onTouchMove: (evt, targetProps) => {
return BrushHelpers.onMouseMove(evt, targetProps);
},
onMouseUp: (evt, targetProps) => {
return BrushHelpers.onMouseUp(evt, targetProps);
Expand Down
11 changes: 2 additions & 9 deletions src/components/containers/victory-cursor-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@ export const cursorContainerMixin = (base) => class VictoryCursorContainer exten
onTouchCancel: () => {
return [];
},
onMouseMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = CursorHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return [];
onMouseMove: (evt, targetProps) => {
return CursorHelpers.onMouseMove(evt, targetProps);
},
onTouchMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = CursorHelpers.onMouseMove(evt, targetProps);
Expand Down
22 changes: 4 additions & 18 deletions src/components/containers/victory-selection-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,11 @@ export const selectionContainerMixin = (base) => class VictorySelectionContainer
onTouchStart: (evt, targetProps) => {
return SelectionHelpers.onMouseDown(evt, targetProps);
},
onMouseMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = SelectionHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
onMouseMove: (evt, targetProps) => {
return SelectionHelpers.onMouseMove(evt, targetProps);
},
onTouchMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = SelectionHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
onTouchMove: (evt, targetProps) => {
return SelectionHelpers.onMouseMove(evt, targetProps);
},
onMouseUp: (evt, targetProps) => {
return SelectionHelpers.onMouseUp(evt, targetProps);
Expand Down
22 changes: 4 additions & 18 deletions src/components/containers/victory-voronoi-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,11 @@ export const voronoiContainerMixin = (base) => class VictoryVoronoiContainer ext
onTouchCancel: (evt, targetProps) => {
return VoronoiHelpers.onMouseLeave(evt, targetProps);
},
onMouseMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = VoronoiHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
onMouseMove: (evt, targetProps) => {
return VoronoiHelpers.onMouseMove(evt, targetProps);
},
onTouchMove: function (evt, targetProps) { // eslint-disable-line object-shorthand
const mutations = VoronoiHelpers.onMouseMove(evt, targetProps);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
onTouchMove: (evt, targetProps) => {
return VoronoiHelpers.onMouseMove(evt, targetProps);
}
}
}, {
Expand Down
38 changes: 7 additions & 31 deletions src/components/containers/victory-zoom-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,44 +61,20 @@ export const zoomContainerMixin = (base) => class VictoryZoomContainer extends b
onTouchCancel: (evt, targetProps) => {
return ZoomHelpers.onMouseLeave(evt, targetProps);
},
// eslint-disable-next-line max-params, object-shorthand
onMouseMove: function (evt, targetProps, eventKey, ctx) {
onMouseMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params
evt.preventDefault();
const mutations = ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);

if (mutations.id !== this.mouseMoveMutationId) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
},
// eslint-disable-next-line max-params, object-shorthand
onTouchMove: function (evt, targetProps, eventKey, ctx) {
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) {
this.mouseMoveMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx);
},
// eslint-disable-next-line max-params, object-shorthand
onWheel: function (evt, targetProps, eventKey, ctx) {
// eslint-disable-next-line max-params
onWheel: (evt, targetProps, eventKey, ctx) => {
if (targetProps.allowZoom) {
evt.preventDefault();
}

const mutations = ZoomHelpers.onWheel(evt, targetProps, eventKey, ctx);

if (mutations.id !== this.wheelMutationId) {
this.wheelMutationId = mutations.id;
return mutations.mutations;
}

return undefined;
return ZoomHelpers.onWheel(evt, targetProps, eventKey, ctx);
}
}
}];
Expand Down
3 changes: 1 addition & 2 deletions src/components/containers/voronoi-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Selection, Data, Helpers } from "victory-core";
import { assign, throttle, isFunction, groupBy, keys, isEqual, includes } from "lodash";
import { voronoi as d3Voronoi } from "d3-voronoi";
import React from "react";
import { attachId } from "../../helpers/event-handlers";

const VoronoiHelpers = {
withinBounds(props, point) {
Expand Down Expand Up @@ -172,7 +171,7 @@ const VoronoiHelpers = {
export default {
onMouseLeave: VoronoiHelpers.onMouseLeave.bind(VoronoiHelpers),
onMouseMove: throttle(
attachId(VoronoiHelpers.onMouseMove.bind(VoronoiHelpers)),
VoronoiHelpers.onMouseMove.bind(VoronoiHelpers),
32, // eslint-disable-line no-magic-numbers
{ leading: true, trailing: false })
};
5 changes: 2 additions & 3 deletions src/components/containers/zoom-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { Children } from "react";
import { Selection, Collection } from "victory-core";
import { throttle, isFunction, defaults } from "lodash";
import { attachId } from "../../helpers/event-handlers";
import Wrapper from "../../helpers/wrapper";

const Helpers = {
Expand Down Expand Up @@ -291,12 +290,12 @@ export default {
onMouseUp: Helpers.onMouseUp.bind(Helpers),
onMouseLeave: Helpers.onMouseLeave.bind(Helpers),
onMouseMove: throttle(
attachId(Helpers.onMouseMove.bind(Helpers)),
Helpers.onMouseMove.bind(Helpers),
16, // eslint-disable-line no-magic-numbers
{ leading: true, trailing: false }
),
onWheel: throttle(
attachId(Helpers.onWheel.bind(Helpers)),
Helpers.onWheel.bind(Helpers),
16, // eslint-disable-line no-magic-numbers
{ leading: true, trailing: false }
)
Expand Down
8 changes: 0 additions & 8 deletions src/helpers/event-handlers.js

This file was deleted.