From e16018ed1eddf3baf598bbda60cf7e1fa7e87a68 Mon Sep 17 00:00:00 2001 From: Eric Yang <59426533+hlyang397@users.noreply.github.com> Date: Thu, 13 Aug 2020 22:26:44 +0800 Subject: [PATCH] Merge pull request #745 from hlyang397/support_mobile_event --- packages/core/src/components/axes/grid-brush.ts | 6 ++++-- packages/core/src/components/axes/zoom-bar.ts | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/axes/grid-brush.ts b/packages/core/src/components/axes/grid-brush.ts index fc66d30429..630242d507 100644 --- a/packages/core/src/components/axes/grid-brush.ts +++ b/packages/core/src/components/axes/grid-brush.ts @@ -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; diff --git a/packages/core/src/components/axes/zoom-bar.ts b/packages/core/src/components/axes/zoom-bar.ts index b8bf6c581e..8e807cf7c5 100644 --- a/packages/core/src/components/axes/zoom-bar.ts +++ b/packages/core/src/components/axes/zoom-bar.ts @@ -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 (