/** * Class adding listener on existing buttons to let the user resizing a window. * The window expects to be displayed in an absolute position. * * With "t" standing for top, "l" for left, "b" for bottom and "r" for right. * The window can implement one or multiple of these buttons: * * * * * * * * * * */ export default class ResizeWindow { private readonly directions; private readonly shadow; private readonly host; private top; private left; private minHeight; private maxHeight; private minWidth; private maxWidth; private height; private width; private originX; private originY; private elements; private readonly className; /** * Create the instance and calls init. */ constructor(shadow: ShadowRoot); /** * Initializes the class by cleaning and attaching events to new existing elements. */ private init; /** * Destroys all elements in the object and removes their onmousedown event listeners. */ destroy(): void; /** * Attaches an event listener to existing element with the specified direction. * @return The element with the attached event listener, or null if no matching element was found. */ private attachEvent; /** * Sets up the resize functionality for an element based on the provided MouseEvent and direction. * Attach onmousemove and onmouseup to document to handle and stop the resize. * @param event - The MouseEvent containing the clientX and clientY coordinates. * @param direction - The direction in which the element should be resized. */ private onResizeStarts; /** * Resizes the element based on the given mouse event and direction. * @param event - The MouseEvent containing the "ondrag" clientX and clientY coordinates. * @param direction - The direction in which the element should be resized. */ private resize; /** * Calculates the new size and position based on the current client coordinates and direction. * @returns an array containing the new top, left, height, and width values in that order. * @private */ private getNewSizeAndPosition; /** * Stops the resizing functionality by clearing the * event listeners for mousemove and mouseup events. */ private stopResize; }