Skip to content

Commit

Permalink
new(localPoint, localPointGeneric): return null for empty events
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Williams committed Oct 22, 2019
1 parent c2a1a50 commit e5a0c80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/vx-event/src/localPoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Point } from '@vx/point';
import localPointGeneric from './localPointGeneric';
import { EventType } from './types';
import { isElement, isEvent } from './typeGuards';
Expand All @@ -11,5 +10,5 @@ export default function localPoint(nodeOrEvent: Element | EventType, maybeEvent?
const node = nodeOrEvent.target as Element;
if (node) return localPointGeneric(node, nodeOrEvent);
}
return new Point({ x: 0, y: 0 });
return null;
}
2 changes: 1 addition & 1 deletion packages/vx-event/src/localPointGeneric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isSVGElement, isSVGGraphicsElement, isSVGSVGElement } from './typeGuard
import getXAndYFromEvent from './getXAndYFromEvent';

export default function localPoint(node: Element, event: EventType) {
if (!node || !event) return new Point({ x: 0, y: 0 });
if (!node || !event) return null;

const coords = getXAndYFromEvent(event);

Expand Down

0 comments on commit e5a0c80

Please sign in to comment.