Skip to content
This repository was archived by the owner on Jun 18, 2018. It is now read-only.

Commit feb6eaa

Browse files
committed
1.0.0
0 parents  commit feb6eaa

21 files changed

+976
-0
lines changed

.babelrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"stage": 0,
3+
"loose": ["es6.modules", "es6.classes"]
4+
}

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
site
2+
dist
3+
lib
4+
**/node_modules
5+
**/webpack*.config.js

.eslintrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "airbnb/base",
3+
"env": {
4+
"browser": true,
5+
"mocha": true,
6+
"node": true
7+
},
8+
"rules": {
9+
"comma-dangle": 0,
10+
"id-length": 0,
11+
"consistent-return": 0
12+
}
13+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.DS_Store
3+
coverage
4+
lib

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Dan Abramov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# react-dnd-html5-backend [![npm package](https://img.shields.io/npm/v/react-dnd-html5-backend.svg?style=flat-square)](https://www.npmjs.org/package/react-dnd-html5-backend)
2+
3+
The default HTML5 backend for [React DnD](http://gaearon.github.io/react-dnd/).
4+
5+
See [the docs](http://gaearon.github.io/react-dnd/docs-html5-backend.html) for usage information.
6+
7+
## License
8+
9+
MIT

dist/ReactDnDHTML5Backend.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "react-dnd-html5-backend",
3+
"version": "1.0.0",
4+
"description": "HTML5 backend for React DnD",
5+
"main": "lib/index.js",
6+
"scripts": {
7+
"clean": "rimraf lib",
8+
"build:lib": "babel src --out-dir lib",
9+
"build:umd": "webpack",
10+
"build": "npm run build:lib && npm run build:umd",
11+
"lint": "eslint .",
12+
"test": "mocha --compilers js:babel/register --recursive",
13+
"test:watch": "npm run test -- --watch",
14+
"prepublish": "npm run lint && npm run clean && npm run test && npm run build"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/gaearon/react-dnd-html5-backend.git"
19+
},
20+
"author": "Dan Abramov <[email protected]> (http://github.com/gaearon)",
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/gaearon/react-dnd-html5-backend/issues"
24+
},
25+
"homepage": "https://github.com/gaearon/react-dnd-html5-backend",
26+
"devDependencies": {
27+
"babel": "^5.8.23",
28+
"babel-eslint": "^4.1.3",
29+
"babel-loader": "^5.3.2",
30+
"eslint": "^1.6.0",
31+
"eslint-config-airbnb": "^0.1.0",
32+
"expect.js": "^0.3.1",
33+
"mocha": "^2.0.1",
34+
"rimraf": "^2.4.3",
35+
"webpack": "^1.12.2"
36+
},
37+
"dependencies": {
38+
"lodash": "^3.10.1"
39+
},
40+
"peerDependencies": {
41+
"react-dnd": "^2.0.0"
42+
}
43+
}

src/BrowserDetector.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import memoize from 'lodash/function/memoize';
2+
3+
export const isFirefox = memoize(() =>
4+
/firefox/i.test(navigator.userAgent)
5+
);
6+
7+
export const isSafari = memoize(() =>
8+
Boolean(window.safari)
9+
);

src/EnterLeaveCounter.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import union from 'lodash/array/union';
2+
import without from 'lodash/array/without';
3+
4+
export default class EnterLeaveCounter {
5+
constructor() {
6+
this.entered = [];
7+
}
8+
9+
enter(enteringNode) {
10+
const previousLength = this.entered.length;
11+
12+
this.entered = union(
13+
this.entered.filter(node =>
14+
document.documentElement.contains(node) &&
15+
(!node.contains || node.contains(enteringNode))
16+
),
17+
[enteringNode]
18+
);
19+
20+
return previousLength === 0 && this.entered.length > 0;
21+
}
22+
23+
leave(leavingNode) {
24+
const previousLength = this.entered.length;
25+
26+
this.entered = without(
27+
this.entered.filter(node =>
28+
document.documentElement.contains(node)
29+
),
30+
leavingNode
31+
);
32+
33+
return previousLength > 0 && this.entered.length === 0;
34+
}
35+
36+
reset() {
37+
this.entered = [];
38+
}
39+
}

0 commit comments

Comments
 (0)