package.src.vaadin-dialog-utils.js Maven / Gradle / Ivy
/**
* @license
* Copyright (c) 2017 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
/**
* Checks if the argument is a touch event and if so, returns a first touch.
* Otherwise, if the mouse event was passed, returns it as is.
* @param {!MouseEvent | !TouchEvent} e
* @return {!MouseEvent | !Touch}
* @protected
*/
export function getMouseOrFirstTouchEvent(e) {
return e.touches ? e.touches[0] : e;
}
/**
* Checks whether a mouse or touch event is in window.
* @param {!MouseEvent | !TouchEvent} e
* @return {boolean}
* @protected
*/
export function eventInWindow(e) {
return e.clientX >= 0 && e.clientX <= window.innerWidth && e.clientY >= 0 && e.clientY <= window.innerHeight;
}