import { InteractionEventsType } from '../hooks/useRippleEffect';
import { baseDOMRect } from '../ripple.types';

export default function isEmpty(obj: object): boolean {
    for (const _i in obj) {
        return false;
    }
    return true;
}

export function maxSize(size: number, cordPos: number): number {
    return Math.max(Math.abs(size - cordPos), cordPos);
}

export function rippleSizeCalculator(
    event: InteractionEventsType,
    rippleDomain: DOMRect | baseDOMRect,
    centralRipple: boolean,
): Array<number> {
    const rippleX: number = !centralRipple
            ? event.clientX - rippleDomain.left
            : rippleDomain.width / 2,
        rippleY: number = !centralRipple
            ? event.clientY - rippleDomain.top
            : rippleDomain.height / 2,
        rippleSizeX: number = maxSize(rippleDomain.width, rippleX) * 2,
        rippleSizeY: number = maxSize(rippleDomain.height, rippleY) * 2,
        rippleS: number = (rippleSizeX ** 2 + rippleSizeY ** 2) ** 0.5;

    return [rippleX, rippleY, rippleS];
}
