import { LitDraggable, LitDragEvent } from "./types";

export class LitDragStart extends Event implements LitDragEvent {
    static readonly eventName = "lit-drag-start";
    offsetX: number = 0;
    offsetY: number = 0;
    node: HTMLElement;
    // container: HTMLElement;
    constructor(source: LitDraggable) {
        super(LitDragStart.eventName, { bubbles: true, composed: true });
        this.offsetX = source.translateX;
        this.offsetY = source.translateY;
        this.node = source.host;
        // this.container = source.container;
    }
}

export class LitDragging extends Event implements LitDragEvent {
    static readonly eventName = "lit-dragging";
    offsetX: number = 0;
    offsetY: number = 0;
    node: HTMLElement;
    // container: HTMLElement;
    constructor(source: LitDraggable) {
        super(LitDragging.eventName, { bubbles: true, composed: true });
        this.offsetX = source.translateX;
        this.offsetY = source.translateY;
        this.node = source.host;
        // this.container = source.container;
    }
}

export class LitDragEnd extends Event implements LitDragEvent {
    static readonly eventName = "lit-drag-end";
    offsetX: number = 0;
    offsetY: number = 0;
    node: HTMLElement;
    // container: HTMLElement;
    constructor(source: LitDraggable) {
        super(LitDragEnd.eventName, { bubbles: true, composed: true });
        this.offsetX = source.initialX;
        this.offsetY = source.initialY;
        this.node = source.host;
        // this.container = source.container;
    }
}

declare global {
    interface GlobalEventHandlersEventMap {
        [LitDragStart.eventName]: LitDragStart;
        [LitDragging.eventName]: LitDragging;
        [LitDragEnd.eventName]: LitDragEnd;
    }
}
