Created
October 19, 2018 12:03
-
-
Save amcdnl/16953c28beb4dd0d94f556699f755473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nativeElement.addEventListener('focus', focusListener, true); | |
nativeElement.addEventListener('blur', blurListener, true); | |
document.addEventListener('keydown', documentKeydownListener, true); | |
document.addEventListener('mousedown', documentMousedownListener, true); | |
document.addEventListener('touchstart', documentTouchstartListener, true); | |
window.addEventListener('focus', windowFocusListener); | |
let documentKeydownListener = () => { | |
this._lastTouchTarget = null; | |
this._setOriginForCurrentEventQueue('keyboard'); | |
}; | |
let documentMousedownListener = () => { | |
if (!this._lastTouchTarget) { | |
this._setOriginForCurrentEventQueue('mouse'); | |
} | |
}; | |
let documentTouchstartListener = (event: TouchEvent) => { | |
if (this._touchTimeoutId != null) { | |
clearTimeout(this._touchTimeoutId); | |
} | |
this._lastTouchTarget = event.target; | |
this._touchTimeoutId = setTimeout(() => this._lastTouchTarget = null, TOUCH_BUFFER_MS); | |
}; | |
let windowFocusListener = () => { | |
this._windowFocused = true; | |
this._windowFocusTimeoutId = setTimeout(() => this._windowFocused = false); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment