react-onclickoutside
Advanced tools
Comparing version 5.9.0 to 5.10.0
10
index.js
@@ -58,3 +58,3 @@ /** | ||
var clickedScrollbar = function(evt) { | ||
return document.documentElement.clientWidth <= evt.clientX; | ||
return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY; | ||
}; | ||
@@ -116,2 +116,8 @@ | ||
getDefaultProps: function() { | ||
return { | ||
excludeScrollbar: config && config.excludeScrollbar | ||
}; | ||
}, | ||
/** | ||
@@ -173,3 +179,3 @@ * Add click listeners to the current document, | ||
this.props.outsideClickIgnoreClass || IGNORE_CLASS, | ||
this.props.excludeScrollbar || false, | ||
this.props.excludeScrollbar, // fallback not needed, prop always exists because of getDefaultProps | ||
this.props.preventDefault || false, | ||
@@ -176,0 +182,0 @@ this.props.stopPropagation || false |
{ | ||
"name": "react-onclickoutside", | ||
"version": "5.9.0", | ||
"version": "5.10.0", | ||
"description": "An onClickOutside wrapper for React components", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -33,2 +33,19 @@ # An onClickOutside wrapper for React components | ||
``` | ||
or: | ||
```js | ||
// ES6 Class Syntax | ||
import React, { Component } from 'react' | ||
import onClickOutside from 'react-onclickoutside' | ||
class MyComponent extends Component { | ||
handleClickOutside = evt => { | ||
// ..handling code goes here... | ||
} | ||
} | ||
export default onClickOutside(MyComponent) | ||
``` | ||
Note that if you try to wrap a React component class without a `handleClickOutside(evt)` handler like this, the HOC will throw an error. In order to use a custom event handler, you can specify the function to be used by the HOC as second parameter | ||
@@ -212,2 +229,12 @@ (this can be useful in environments like TypeScript, where the fact that the wrapped component does not implement the handler can be flagged at compile-time): | ||
Alternatively, you can specify this behavior as default for all instances of your component passing a configuration object as second parameter: | ||
```js | ||
var MyComponent = onClickOutside(React.createClass({ | ||
... | ||
}), { | ||
excludeScrollbar: true | ||
}); | ||
``` | ||
## Regulating `evt.preventDefault()` and `evt.stopPropagation()` | ||
@@ -214,0 +241,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26283
279
305