Skip to content

Commit

Permalink
Merge pull request #745 from hlyang397/support_mobile_event
Browse files Browse the repository at this point in the history
  • Loading branch information
hlyang397 authored Aug 13, 2020
1 parent 8ed23b1 commit e16018e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/components/axes/grid-brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ export class ChartBrush extends Component {
xScale.invert(selection[0]),
xScale.invert(selection[1])
];

if (
selection != null &&
event.sourceEvent != null &&
(event.sourceEvent.type === "mousemove" ||
event.sourceEvent.type === "mouseup" ||
event.sourceEvent.type === "mousedown")
event.sourceEvent.type === "mousedown" ||
event.sourceEvent.type === "touchstart" ||
event.sourceEvent.type === "touchmove" ||
event.sourceEvent.type === "touchend")
) {
// dispatch selection events
let zoomBarEventType;
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/components/axes/zoom-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,15 @@ export class ZoomBar extends Component {
this.updateBrushHandle(this.getContainerSVG(), selection, newDomain);

// be aware that the value of d3.event changes during an event!
// update zoomDomain only if the event comes from mouse event
// update zoomDomain only if the event comes from mouse/touch event
if (
event.sourceEvent != null &&
(event.sourceEvent.type === "mousemove" ||
event.sourceEvent.type === "mouseup" ||
event.sourceEvent.type === "mousedown")
event.sourceEvent.type === "mousedown" ||
event.sourceEvent.type === "touchstart" ||
event.sourceEvent.type === "touchmove" ||
event.sourceEvent.type === "touchend")
) {
// only if zoomDomain is never set or needs update
if (
Expand Down

0 comments on commit e16018e

Please sign in to comment.