Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ var ClickOutside = function (_Component) {
if (el && !el.contains(e.target)) onClickOutside(e);
};

_this.resetIsTouch = function () {
return _this.isTouch = false;
};

_this.getContainer = _this.getContainer.bind(_this);
_this.isTouch = false;
return _this;
Expand Down Expand Up @@ -72,12 +76,14 @@ var ClickOutside = function (_Component) {
value: function componentDidMount() {
document.addEventListener('touchend', this.handle, true);
document.addEventListener('click', this.handle, true);
window.addEventListener('resize', this.resetIsTouch, true);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
document.removeEventListener('touchend', this.handle, true);
document.removeEventListener('click', this.handle, true);
window.removeEventListener('resize', this.resetIsTouch, true);
}
}]);

Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export default class ClickOutside extends Component {
componentDidMount() {
document.addEventListener('touchend', this.handle, true)
document.addEventListener('click', this.handle, true)
window.addEventListener('resize', this.resetIsTouch, true)
}

componentWillUnmount() {
document.removeEventListener('touchend', this.handle, true)
document.removeEventListener('click', this.handle, true)
window.removeEventListener('resize', this.resetIsTouch, true)
}

handle = e => {
Expand All @@ -38,4 +40,6 @@ export default class ClickOutside extends Component {
const el = this.container
if (el && !el.contains(e.target)) onClickOutside(e)
}

resetIsTouch = () => this.isTouch = false
}