Skip to content
This repository was archived by the owner on May 26, 2022. It is now read-only.

Commit f40948f

Browse files
author
Adam
committed
fix touch dragndrop
1 parent 8ed8dab commit f40948f

File tree

5 files changed

+57
-21
lines changed

5 files changed

+57
-21
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"react": "^16.3.2",
3030
"react-dev-utils": "^6.0.0-next.b2fd8db8",
3131
"react-dnd": "^2.6.0",
32-
"react-dnd-html5-backend": "^2.6.0",
32+
"react-dnd-multi-backend": "^3.1.2",
3333
"react-dom": "^16.3.2",
3434
"react-keydown": "^1.9.7",
3535
"react-md": "^1.3.0",
@@ -52,7 +52,7 @@
5252
"@types/jest": "^22.2.3",
5353
"@types/react": "16.3.13",
5454
"@types/react-dnd": "^2.0.36",
55-
"@types/react-dnd-html5-backend": "^2.1.9",
55+
"@types/react-dnd-multi-backend": "^3.0.1",
5656
"@types/react-dom": "^16.0.5",
5757
"@types/react-redux": "5.0.19",
5858
"gh-pages": "^1.1.0",

src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as React from 'react'
2+
import { compose } from 'redux'
23
import { connect } from 'react-redux'
4+
import { DragDropContext } from 'react-dnd'
35
import keydown from 'react-keydown/es'
46
import styled from 'styled-components'
57
import { Divider } from 'react-md/lib/Dividers'
@@ -8,6 +10,7 @@ import { startTimer, stopTimer, setTime } from '@state/actions/timerActions'
810
import { TimerContainer } from './containers/Timer'
911
import { UserContainer } from './containers/Users'
1012
import { GitHubLink } from './components/GitHubLink'
13+
import { multiBackend } from './utils/dragDropContext'
1114
import { Time } from './time'
1215
import { IState } from './state'
1316

@@ -77,4 +80,7 @@ export class AppComponent extends React.Component<
7780
}
7881
}
7982

80-
export const App = connect(mapState, mapActions)(AppComponent)
83+
export const App = compose(
84+
connect(mapState, mapActions),
85+
DragDropContext(multiBackend)
86+
)(AppComponent)

src/index.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as React from 'react'
22
import { render } from 'react-dom'
33
import { Provider } from 'react-redux'
4-
import { DragDropContextProvider as DnDCProvider } from 'react-dnd'
5-
import * as HTML5Backend from 'react-dnd-html5-backend'
4+
65
import 'rxjs/add/operator/do'
76
import 'rxjs/add/operator/filter'
87
import 'rxjs/add/operator/mapTo'
@@ -24,11 +23,9 @@ requestPermission()
2423

2524
render(
2625
<Provider store={store}>
27-
<DnDCProvider backend={HTML5Backend}>
28-
<React.Fragment>
29-
<App />
30-
</React.Fragment>
31-
</DnDCProvider>
26+
<React.Fragment>
27+
<App />
28+
</React.Fragment>
3229
</Provider>,
3330
document.getElementById('root') as HTMLElement
3431
)
@@ -39,11 +36,9 @@ if ((module as any).hot) {
3936

4037
render(
4138
<Provider store={store}>
42-
<DnDCProvider backend={HTML5Backend}>
43-
<React.Fragment>
44-
<NextApp />
45-
</React.Fragment>
46-
</DnDCProvider>
39+
<React.Fragment>
40+
<NextApp />
41+
</React.Fragment>
4742
</Provider>,
4843
document.getElementById('root')
4944
)

src/utils/dragDropContext.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import MultiBackend from 'react-dnd-multi-backend'
2+
import HTML5toTouch from 'react-dnd-multi-backend/lib/HTML5toTouch'
3+
4+
export const multiBackend = MultiBackend(HTML5toTouch)

yarn.lock

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,11 @@
578578
version "10.0.3"
579579
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.0.3.tgz#1f89840c7aac2406cc43a2ecad98fc02a8e130e4"
580580

581-
"@types/react-dnd-html5-backend@^2.1.9":
582-
version "2.1.9"
583-
resolved "https://registry.yarnpkg.com/@types/react-dnd-html5-backend/-/react-dnd-html5-backend-2.1.9.tgz#dfc9efe2a68bd12407815a2d61ddfd18bb8686fb"
581+
"@types/react-dnd-multi-backend@^3.0.1":
582+
version "3.0.1"
583+
resolved "https://registry.yarnpkg.com/@types/react-dnd-multi-backend/-/react-dnd-multi-backend-3.0.1.tgz#9cdf9bfc23e3c12fb5bc47629181ae01e366c979"
584584
dependencies:
585+
"@types/react" "*"
585586
"@types/react-dnd" "*"
586587

587588
"@types/react-dnd@*", "@types/react-dnd@^2.0.36":
@@ -2320,6 +2321,10 @@ dnd-core@^2.6.0:
23202321
lodash "^4.2.0"
23212322
redux "^3.7.1"
23222323

2324+
dnd-multi-backend@^3.1.0:
2325+
version "3.1.0"
2326+
resolved "https://registry.yarnpkg.com/dnd-multi-backend/-/dnd-multi-backend-3.1.0.tgz#595fef292a47634da52014f8f0c70e06dcf1c76b"
2327+
23232328
dns-equal@^1.0.0:
23242329
version "1.0.0"
23252330
resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
@@ -6344,13 +6349,39 @@ react-dev-utils@^6.0.0-next.b2fd8db8:
63446349
strip-ansi "4.0.0"
63456350
text-table "0.2.0"
63466351

6347-
react-dnd-html5-backend@^2.6.0:
6352+
react-dnd-html5-backend@*:
63486353
version "2.6.0"
63496354
resolved "https://registry.yarnpkg.com/react-dnd-html5-backend/-/react-dnd-html5-backend-2.6.0.tgz#590cd1cca78441bb274edd571fef4c0b16ddcf8e"
63506355
dependencies:
63516356
lodash "^4.2.0"
63526357

6353-
react-dnd@^2.6.0:
6358+
react-dnd-multi-backend@^3.1.2:
6359+
version "3.1.2"
6360+
resolved "https://registry.yarnpkg.com/react-dnd-multi-backend/-/react-dnd-multi-backend-3.1.2.tgz#520493b7558bc7605ec218da12ddcfacfaec949a"
6361+
dependencies:
6362+
dnd-multi-backend "^3.1.0"
6363+
prop-types "^15.5.8"
6364+
react "*"
6365+
react-dnd-html5-backend "*"
6366+
react-dnd-preview "^3.0.7"
6367+
react-dnd-touch-backend "^0.3.13"
6368+
6369+
react-dnd-preview@^3.0.7:
6370+
version "3.0.7"
6371+
resolved "https://registry.yarnpkg.com/react-dnd-preview/-/react-dnd-preview-3.0.7.tgz#555da2123de675a43169cf5c9e7028e644e3f1fb"
6372+
dependencies:
6373+
prop-types "^15.5.8"
6374+
react "*"
6375+
react-dnd "*"
6376+
6377+
react-dnd-touch-backend@^0.3.13:
6378+
version "0.3.21"
6379+
resolved "https://registry.yarnpkg.com/react-dnd-touch-backend/-/react-dnd-touch-backend-0.3.21.tgz#13951348511aed62c47705c82ed21e5e030fcce9"
6380+
dependencies:
6381+
invariant "^2.2.2"
6382+
react-dnd "^2.5.4"
6383+
6384+
react-dnd@*, react-dnd@^2.5.4, react-dnd@^2.6.0:
63546385
version "2.6.0"
63556386
resolved "https://registry.yarnpkg.com/react-dnd/-/react-dnd-2.6.0.tgz#7fa25676cf827d58a891293e3c1ab59da002545a"
63566387
dependencies:
@@ -6469,7 +6500,7 @@ react-transition-group@^1.2.1:
64696500
prop-types "^15.5.6"
64706501
warning "^3.0.0"
64716502

6472-
react@^16.3.2:
6503+
react@*, react@^16.3.2:
64736504
version "16.3.2"
64746505
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
64756506
dependencies:

0 commit comments

Comments
 (0)