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

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Oct 14, 2015
0 parents commit feb6eaa
Show file tree
Hide file tree
Showing 21 changed files with 976 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"stage": 0,
"loose": ["es6.modules", "es6.classes"]
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
site
dist
lib
**/node_modules
**/webpack*.config.js
13 changes: 13 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "airbnb/base",
"env": {
"browser": true,
"mocha": true,
"node": true
},
"rules": {
"comma-dangle": 0,
"id-length": 0,
"consistent-return": 0
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.DS_Store
coverage
lib
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Dan Abramov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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)

The default HTML5 backend for [React DnD](http://gaearon.github.io/react-dnd/).

See [the docs](http://gaearon.github.io/react-dnd/docs-html5-backend.html) for usage information.

## License

MIT
1 change: 1 addition & 0 deletions dist/ReactDnDHTML5Backend.min.js

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "react-dnd-html5-backend",
"version": "1.0.0",
"description": "HTML5 backend for React DnD",
"main": "lib/index.js",
"scripts": {
"clean": "rimraf lib",
"build:lib": "babel src --out-dir lib",
"build:umd": "webpack",
"build": "npm run build:lib && npm run build:umd",
"lint": "eslint .",
"test": "mocha --compilers js:babel/register --recursive",
"test:watch": "npm run test -- --watch",
"prepublish": "npm run lint && npm run clean && npm run test && npm run build"
},
"repository": {
"type": "git",
"url": "https://github.com/gaearon/react-dnd-html5-backend.git"
},
"author": "Dan Abramov <[email protected]> (http://github.com/gaearon)",
"license": "MIT",
"bugs": {
"url": "https://github.com/gaearon/react-dnd-html5-backend/issues"
},
"homepage": "https://github.com/gaearon/react-dnd-html5-backend",
"devDependencies": {
"babel": "^5.8.23",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"eslint": "^1.6.0",
"eslint-config-airbnb": "^0.1.0",
"expect.js": "^0.3.1",
"mocha": "^2.0.1",
"rimraf": "^2.4.3",
"webpack": "^1.12.2"
},
"dependencies": {
"lodash": "^3.10.1"
},
"peerDependencies": {
"react-dnd": "^2.0.0"
}
}
9 changes: 9 additions & 0 deletions src/BrowserDetector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import memoize from 'lodash/function/memoize';

export const isFirefox = memoize(() =>
/firefox/i.test(navigator.userAgent)
);

export const isSafari = memoize(() =>
Boolean(window.safari)
);
39 changes: 39 additions & 0 deletions src/EnterLeaveCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import union from 'lodash/array/union';
import without from 'lodash/array/without';

export default class EnterLeaveCounter {
constructor() {
this.entered = [];
}

enter(enteringNode) {
const previousLength = this.entered.length;

this.entered = union(
this.entered.filter(node =>
document.documentElement.contains(node) &&
(!node.contains || node.contains(enteringNode))
),
[enteringNode]
);

return previousLength === 0 && this.entered.length > 0;
}

leave(leavingNode) {
const previousLength = this.entered.length;

this.entered = without(
this.entered.filter(node =>
document.documentElement.contains(node)
),
leavingNode
);

return previousLength > 0 && this.entered.length === 0;
}

reset() {
this.entered = [];
}
}
Loading

0 comments on commit feb6eaa

Please sign in to comment.