Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleTouchStart() {
if (!focusAdded) {
window.addEventListener("focus", handleFocus, true);
focusAdded = true;
}
if (!touchEndAdded) {
addTouchEvent(window, "end", handleTouchEnd, true);
touchEndAdded = true;
}
}
public componentDidMount() {
window.addEventListener("blur", this.handleBlur, true);
window.addEventListener("focus", this.handleFocus, true);
window.addEventListener("keydown", this.handleKeyDown, true);
addTouchEvent(window, "start", this.handleTouchStart, true);
}
export function startListening() {
listeners += 1;
if (!touchStartAdded) {
addTouchEvent(window, "start", handleTouchStart);
touchStartAdded = true;
}
}
private updateTouch = () => {
if (!this.props.disableTouchFixes) {
addTouchEvent(window, "move", this.handleTouchMove);
} else {
removeTouchEvent(window, "move", this.handleTouchMove);
}
};
private handleTouchStart = (event: TouchEvent) => {
this.touched = true;
addTouchEvent(window, "end", this.handleTouchEnd, true);
};