Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public componentWillUnmount() {
this.clearShowTimeout();
this.clearFocusTimeout();
this.clearHoverModeTimeout();
window.removeEventListener("blur", this.handleBlur, true);
window.removeEventListener("focus", this.handleFocus, true);
window.removeEventListener("keydown", this.handleKeyDown, true);
removeTouchEvent(window, "start", this.handleTouchStart, true);
removeTouchEvent(window, "end", this.handleTouchEnd, true);
this.clearContainers();
}
private handleTouchEnd = (event: TouchEvent) => {
removeTouchEvent(window, "end", this.handleTouchEnd, true);
window.requestAnimationFrame(() => {
this.touched = false;
});
};
}
export function stopListening() {
listeners = Math.max(0, listeners - 1);
if (listeners === 0) {
window.clearTimeout(timeout);
timeout = undefined;
if (focusAdded) {
window.removeEventListener("focus", handleFocus, true);
focusAdded = false;
}
if (touchStartAdded) {
removeTouchEvent(window, "start", handleTouchStart);
touchStartAdded = false;
}
}
}
public componentWillUnmount() {
window.clearTimeout(this.touchMoveTimeout);
removeTouchEvent(window, "move", this.handleTouchMove);
if (this.resizeHandler) {
this.resizeHandler.remove(this.handleResize);
}
if (!this.props.disableTouchKeyboardFixes) {
stopListening();
}
}
public componentWillUnmount() {
this.clearShowTimeout();
this.clearFocusTimeout();
this.clearHoverModeTimeout();
window.removeEventListener("blur", this.handleBlur, true);
window.removeEventListener("focus", this.handleFocus, true);
window.removeEventListener("keydown", this.handleKeyDown, true);
removeTouchEvent(window, "start", this.handleTouchStart, true);
removeTouchEvent(window, "end", this.handleTouchEnd, true);
this.clearContainers();
}
function handleTouchEnd() {
removeTouchEvent(window, "end", handleTouchEnd, true);
touchEndAdded = false;
window.clearTimeout(focusResetTimeout);
focusResetTimeout = window.setTimeout(() => {
focusResetTimeout = undefined;
if (focusAdded) {
window.removeEventListener("focus", handleFocus, true);
focusAdded = false;
}
}, KEYBOARD_WAIT);
}
private updateTouch = () => {
if (!this.props.disableTouchFixes) {
addTouchEvent(window, "move", this.handleTouchMove);
} else {
removeTouchEvent(window, "move", this.handleTouchMove);
}
};