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

Commit

Permalink
correctly throttle victory-brush-container and add trailing false
Browse files Browse the repository at this point in the history
  • Loading branch information
NgoKnows committed Mar 21, 2017
1 parent 0371fc5 commit 432ccf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/components/containers/brush-helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Selection} from "victory-core";
import { assign, throttle, isFunction, isEqual, defaults } from "lodash";

import { attachId } from "../../helpers/event-handlers.js";

const Helpers = {
withinBounds(point, bounds, padding) {
Expand Down Expand Up @@ -260,5 +260,9 @@ export default {
onMouseDown: Helpers.onMouseDown.bind(Helpers),
onMouseUp: Helpers.onMouseUp.bind(Helpers),
onMouseLeave: Helpers.onMouseLeave.bind(Helpers),
onMouseMove: throttle(Helpers.onMouseMove.bind(Helpers), 16, {leading: true})
onMouseMove: throttle(
attachId(Helpers.onMouseMove.bind(Helpers)),
16,
{leading: true, trailing: false}
)
};
11 changes: 6 additions & 5 deletions src/components/containers/victory-brush-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ export default class VictoryBrushContainer extends VictoryContainer {
target: "parent",
eventHandlers: {
onMouseDown: (evt, targetProps) => {
BrushHelpers.onMouseMove.cancel();
return BrushHelpers.onMouseDown(evt, targetProps);
},
onMouseMove: (evt, targetProps) => {
evt.persist();
return BrushHelpers.onMouseMove(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;
}
},
onMouseUp: (evt, targetProps) => {
BrushHelpers.onMouseMove.cancel();
return BrushHelpers.onMouseUp(evt, targetProps);
},
onMouseLeave: (evt, targetProps) => {
BrushHelpers.onMouseMove.cancel();
return BrushHelpers.onMouseLeave(evt, targetProps);
}
}
Expand Down

0 comments on commit 432ccf1

Please sign in to comment.