diff --git a/.eslintrc b/.eslintrc
index bdc2c96b..7945674a 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -8,16 +8,16 @@
"rules": {
"no-unused-expressions": 0,
"chai-friendly/no-unused-expressions": 2,
- "import/default": "warn",
- "import/export": "warn",
- "import/named": "warn",
- "import/namespace": "warn",
- "import/no-amd": "warn",
- "import/no-duplicates": "warn",
- "import/no-extraneous-dependencies": "warn",
- "import/no-named-as-default": "warn",
- "import/no-named-as-default-member": "warn",
- "import/no-unresolved": ["warn", { "commonjs": true }],
+ "import/default": "error",
+ "import/export": "error",
+ "import/named": "error",
+ "import/namespace": "error",
+ "import/no-amd": "error",
+ "import/no-duplicates": "error",
+ "import/no-extraneous-dependencies": "error",
+ "import/no-named-as-default": "error",
+ "import/no-named-as-default-member": "error",
+ "import/no-unresolved": ["error", { "commonjs": true }],
"indent": ["error", 4]
}
}
diff --git a/README.md b/README.md
index c5d764a1..a2727113 100644
--- a/README.md
+++ b/README.md
@@ -20,11 +20,6 @@ See the [react-cursor-position demo site](https://ethanselzer.github.io/react-cu
Experiment with react-cursor-position [live on CodePen](http://codepen.io/ethanselzer/pen/ryayLK).
-## Related Project
-
-For hover monitoring, please consider [react-hover-observer](https://www.npmjs.com/package/react-hover-observer).
-It has a similar interface to react-cursor-position, and can be used in combination with it.
-
## Installation
```sh
@@ -45,13 +40,17 @@ import ReactCursorPosition from 'react-cursor-position';
```
-react-cursor-position wraps its children in a div, which cursor and touch position
+react-cursor-position wraps its children in a div, which mouse and touch position
are plotted relative to.
Each child component will receive the following props:
```JavaScript
{
+ detectedEnvironment: {
+ isMouseDetected: false,
+ isTouchDetected: false,
+ },
elementDimensions: {
width: Number,
height: Number
@@ -66,19 +65,20 @@ Each child component will receive the following props:
```
This structure may be customized by implementing `mapChildProps` API feature.
+The information in `detectedEnvironment` is acquired from interaction with this component and will be unset until the first interaction.
+
## Props API
All props are optional.
**className** : String - CSS class name(s) to be applied to the div rendered by react-cursor-position.
-**style** : Object - Style to be applied to the div rendered by react-cursor-position.
+**hoverDelayInMs** : Number - Amount of time, in milliseconds, to delay hover interaction from activating. Defaults to 0.
-**onActivationChanged** : Function - Called when the component is active.
-Function receives one parameter with the signature `{ isActive: Boolean }`.
+**hoverOffDelayInMs** : Number - Amount of time, in milliseconds, to delay hover off interaciton from deactivating. Defaults to 0.
-**onPositionChanged** : Function - Called when cursor or touch position changes.
-Function receives one parameter with the signature `{ elementDimensions: { width: Number, height: Number }, isPositionOutside: Boolean, position: { x: Number, y: Number } }`.
+**isActivatedOnTouch** : Boolean - Activate immediately on touch. Scrolling may not be possible when scroll
+gesture begins on target area. Recommended only when scrolling is not an expected use case. Defaults to false.
**mapChildProps** : Function - Model child component props to your custom shape.
Function receives one parameter with the signature
@@ -86,16 +86,24 @@ Function receives one parameter with the signature
It should return an object that is compatible with the props interface of your child components.
See [example demo](https://ethanselzer.github.io/react-cursor-position/#/map-child-props).
-**shouldDecorateChildren** : Boolean - Suppress decoration of child components by
-setting this prop false. Defaults to true.
+**onActivationChanged** : Function - Called when the component is active.
+Function receives one parameter with the signature `{ isActive: Boolean }`.
-**isActivatedOnTouch** : Boolean - Activate immediately on touch. Scrolling may not be possible when scroll
-gesture begins on target area. Recommended only when scrolling is not an expected use case. Defaults to false.
+**onPositionChanged** : Function - Called when cursor or touch position changes.
+Function receives one parameter with the signature `{ elementDimensions: { width: Number, height: Number }, isPositionOutside: Boolean, position: { x: Number, y: Number } }`.
+
+**onDetectedEnvironmentChanged** : Function - Called when detected environment (mouse or touch) changes.
+Function receives one parameter with the signature `{ isMouseDetected: Boolean, isTouchDetected: Boolean }`.
**pressDuration** : Number - Milliseconds delay before press gesture is activated. Defaults to 500.
**pressMoveThreshold** : Number - Amount of movement, in pixels, allowed during press gesture detection. Defaults to 5.
+**shouldDecorateChildren** : Boolean - Suppress decoration of child components by
+setting this prop false. Defaults to true.
+
+**style** : Object - Style to be applied to the div rendered by react-cursor-position.
+
See API Examples section of the [demo site](https://ethanselzer.github.io/react-cursor-position/#/) for more.
## Support
diff --git a/example/package.json b/example/package.json
index a420acfe..4a62cb26 100644
--- a/example/package.json
+++ b/example/package.json
@@ -1,21 +1,20 @@
{
"name": "react-cursor-position-example",
- "version": "0.1.0",
+ "version": "1.0.0",
"homepage": "http://ethanselzer.github.io/react-cursor-position",
"devDependencies": {
- "react-scripts": "^0.9.5"
+ "react-scripts": "^1.0.10"
},
"dependencies": {
"bootstrap": "^3.3.7",
- "highlightjs": "^9.10.0",
- "prop-types": "^15.5.8",
- "react": "^15.5.4",
- "react-bootstrap": "^0.31.0",
- "react-dom": "^15.5.4",
- "react-helmet": "^5.0.3",
- "react-image-magnify": "^1.4.8",
+ "prop-types": "^15.5.10",
+ "react": "^15.6.1",
+ "react-bootstrap": "^0.31.1",
+ "react-dom": "^15.6.1",
+ "react-helmet": "^5.1.3",
+ "react-image-magnify": "^1.8.0",
"react-router": "3.0.5",
- "react-syntax-highlighter": "^5.5.2"
+ "react-syntax-highlighter": "^5.6.2"
},
"scripts": {
"start": "react-scripts start",
diff --git a/example/public/hover-delay.html b/example/public/hover-delay.html
new file mode 100644
index 00000000..657eb77b
--- /dev/null
+++ b/example/public/hover-delay.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+ Class Name | Code Example | React Cursor Position
+
+
+