Skip to content

Commit

Permalink
fix(nodes): cehck if touchevent exists fixes #188
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed May 5, 2020
1 parent 6c641a1 commit 98978df
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions dist/ReactFlow.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ReactFlow.esm.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions dist/ReactFlow.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ReactFlow.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-flow-renderer",
"version": "1.0.1",
"version": "1.1.0",
"main": "dist/ReactFlow.js",
"module": "dist/ReactFlow.esm.js",
"license": "MIT",
Expand Down
7 changes: 5 additions & 2 deletions src/components/Nodes/wrapNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { Provider } from '../../contexts/NodeIdContext';
import store from '../../store';
import { Node, XYPosition, Transform, ElementId, NodeComponentProps, WrapNodeProps } from '../../types';

const getMouseEvent = (evt: MouseEvent | TouchEvent) =>
typeof TouchEvent !== 'undefined' && evt instanceof TouchEvent ? evt.touches[0] : (evt as MouseEvent);

const onStart = (
evt: MouseEvent | TouchEvent,
onClick: (node: Node) => void,
Expand All @@ -17,7 +20,7 @@ const onStart = (
transform: Transform,
position: XYPosition
): false | void => {
const startEvt = evt instanceof TouchEvent ? evt.touches[0] : evt;
const startEvt = getMouseEvent(evt);

const scaledClient: XYPosition = {
x: startEvt.clientX * (1 / transform[2]),
Expand All @@ -39,7 +42,7 @@ const onDrag = (
offset: XYPosition,
transform: Transform
): void => {
const dragEvt = evt instanceof TouchEvent ? evt.touches[0] : evt;
const dragEvt = getMouseEvent(evt);

const scaledClient = {
x: dragEvt.clientX * (1 / transform[2]),
Expand Down

0 comments on commit 98978df

Please sign in to comment.