/**
 * @since Last modified: 2024-08-06 22:17:30
 * @function isOutside
 * @description Determine whether the current touch point is outside the element's rectangular boundary.
 * @param {object} ev  - Can be any data
 * @param {getEl} elem  - Target element.
 * @returns {boolean}  - Return true or false
 * @see {@link https://codepen.io/axui/pen/wvLKRdx|demo @ codepen}
 * @example
 */
'use strict';
import { T_obj, T_sel } from '../../../types/ax';
import getEl from './getEl';
import isMobi from './isMobi';
const isOutside = (ev: T_obj, elem: T_sel): boolean => {
    let el = getEl(elem);
    if (!el || !ev) return true;
    let point = isMobi ? { x: ev.targetTouches[0].clientX, y: ev.targetTouches[0].clientY } : { x: ev.clientX, y: ev.clientY },
        lt = { x: el.getBoundingClientRect().left, y: el.getBoundingClientRect().top },
        rb = { x: lt.x + el.offsetWidth, y: lt.y + el.offsetHeight }
    return (point.x < lt.x || point.x > rb.x || point.y < lt.y || point.y > rb.y) ? true : false;
}
export default isOutside;
