Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #845 when brush is not responding to touch on mobile #1874

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
30 changes: 15 additions & 15 deletions packages/visx-brush/src/BaseBrush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export type BaseBrushProps = {
onBrushStart?: (start: BaseBrushState['start']) => void;
onBrushEnd?: (state: BaseBrushState) => void;
selectedBoxStyle: React.SVGProps<SVGRectElement>;
onMouseLeave?: (event: PointerHandlerEvent) => void;
onMouseUp?: (event: PointerHandlerEvent) => void;
onMouseMove?: (event: PointerHandlerEvent) => void;
onPointerLeave?: (event: PointerHandlerEvent) => void;
onPointerUp?: (event: PointerHandlerEvent) => void;
onPointerMove?: (event: PointerHandlerEvent) => void;
onClick?: (event: PointerHandlerEvent) => void;
clickSensitivity: number;
disableDraggingSelection: boolean;
Expand Down Expand Up @@ -100,9 +100,9 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
resizeTriggerAreas: ['left', 'right'],
onBrushStart: null,
onBrushEnd: null,
onMouseLeave: null,
onMouseUp: null,
onMouseMove: null,
onPointerLeave: null,
onPointerUp: null,
onPointerMove: null,
onClick: null,
disableDraggingSelection: false,
disableDraggingOverlay: false,
Expand Down Expand Up @@ -572,9 +572,9 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
left,
width: stageWidth,
height: stageHeight,
onMouseLeave,
onMouseUp,
onMouseMove,
onPointerLeave,
onPointerUp,
onPointerMove,
onBrushEnd,
onClick,
resizeTriggerAreas,
Expand Down Expand Up @@ -630,15 +630,15 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
dragStart(event);
}}
onPointerLeave={(event: PointerHandlerEvent) => {
if (onMouseLeave) onMouseLeave(event);
if (onPointerLeave) onPointerLeave(event);
}}
onPointerMove={(event: PointerHandlerEvent) => {
if (!isDragging && onMouseMove) onMouseMove(event);
if (!isDragging && onPointerMove) onPointerMove(event);
if (isDragging) dragMove(event);
}}
onPointerUp={(event: PointerHandlerEvent) => {
this.mouseUpTime = Date.now();
if (onMouseUp) onMouseUp(event);
if (onPointerUp) onPointerUp(event);
dragEnd(event);
}}
style={{ cursor: 'crosshair' }}
Expand All @@ -659,9 +659,9 @@ export default class BaseBrush extends React.Component<BaseBrushProps, BaseBrush
disableDraggingSelection={disableDraggingSelection}
onBrushEnd={onBrushEnd}
onBrushStart={this.handleBrushStart}
onMouseLeave={onMouseLeave}
onMouseMove={onMouseMove}
onMouseUp={onMouseUp}
onPointerLeave={onPointerLeave}
onPointerMove={onPointerMove}
onPointerUp={onPointerUp}
onMoveSelectionChange={this.handleBrushingTypeChange}
onClick={onClick}
selectedBoxStyle={selectedBoxStyle}
Expand Down
16 changes: 8 additions & 8 deletions packages/visx-brush/src/Brush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export type BrushProps = {
/** Callback invoked on mouse up when a Brush size is being updated. */
onBrushEnd?: (bounds: Bounds | null) => void;
/** Callback invoked on mouse move in Brush stage when *not* dragging. */
onMouseMove?: BaseBrushProps['onMouseMove'];
onPointerMove?: BaseBrushProps['onPointerMove'];
/** Callback invoked on mouse leave from Brush stage when *not* dragging. */
onMouseLeave?: BaseBrushProps['onMouseLeave'];
onPointerLeave?: BaseBrushProps['onPointerLeave'];
/** Callback invoked on Brush stage click. */
onClick?: BaseBrushProps['onClick'];
/** Margin subtracted from Brush stage dimensions. */
Expand Down Expand Up @@ -98,8 +98,8 @@ class Brush extends Component<BrushProps> {
onBrushEnd: null,
disableDraggingSelection: false,
resetOnEnd: false,
onMouseMove: null,
onMouseLeave: null,
onPointerMove: null,
onPointerLeave: null,
onClick: null,
useWindowMoveEvents: false,
renderBrushHandles: null,
Expand Down Expand Up @@ -186,8 +186,8 @@ class Brush extends Component<BrushProps> {
disableDraggingSelection,
disableDraggingOverlay,
resetOnEnd,
onMouseLeave,
onMouseMove,
onPointerLeave,
onPointerMove,
onClick,
handleSize,
useWindowMoveEvents,
Expand Down Expand Up @@ -251,8 +251,8 @@ class Brush extends Component<BrushProps> {
onBrushStart={this.handleBrushStart}
onChange={this.handleChange}
onClick={onClick}
onMouseLeave={onMouseLeave}
onMouseMove={onMouseMove}
onPointerLeave={onPointerLeave}
onPointerMove={onPointerMove}
useWindowMoveEvents={useWindowMoveEvents}
renderBrushHandle={renderBrushHandle}
/>
Expand Down
24 changes: 12 additions & 12 deletions packages/visx-brush/src/BrushSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export type BrushSelectionProps = {
onBrushStart?: (brush: DragArgs) => void;
onBrushEnd?: (brush: BrushState) => void;
disableDraggingSelection: boolean;
onMouseLeave: PointerHandler;
onMouseMove: PointerHandler;
onMouseUp: PointerHandler;
onPointerLeave: PointerHandler;
onPointerMove: PointerHandler;
onPointerUp: PointerHandler;
onClick: PointerHandler;
selectedBoxStyle: React.SVGProps<SVGRectElement>;
isControlled?: boolean;
Expand All @@ -34,9 +34,9 @@ export default class BrushSelection extends React.Component<
BrushSelectionProps & Omit<React.SVGProps<SVGRectElement>, keyof BrushSelectionProps>
> {
static defaultProps = {
onMouseLeave: null,
onMouseUp: null,
onMouseMove: null,
onPointerLeave: null,
onPointerUp: null,
onPointerMove: null,
onClick: null,
};

Expand Down Expand Up @@ -122,9 +122,9 @@ export default class BrushSelection extends React.Component<
stageHeight,
brush,
disableDraggingSelection,
onMouseLeave,
onMouseMove,
onMouseUp,
onPointerLeave,
onPointerMove,
onPointerUp,
onClick,
selectedBoxStyle,
isControlled,
Expand Down Expand Up @@ -162,17 +162,17 @@ export default class BrushSelection extends React.Component<
className="visx-brush-selection"
onPointerDown={disableDraggingSelection ? undefined : dragStart}
onPointerLeave={(event) => {
if (onMouseLeave) onMouseLeave(event);
if (onPointerLeave) onPointerLeave(event);
}}
onPointerMove={(event) => {
dragMove(event);
if (onMouseMove) onMouseMove(event);
if (onPointerMove) onPointerMove(event);
}}
onPointerUp={(event) => {
if (!isControlled) {
dragEnd(event);
}
if (onMouseUp) onMouseUp(event);
if (onPointerUp) onPointerUp(event);
}}
onClick={(event) => {
if (onClick) onClick(event as React.PointerEvent<SVGRectElement>);
Expand Down