UNPKG

goban

Version:

[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

29 lines (28 loc) 1.58 kB
/** On iOS devices they limit the number of canvases we create to a a very low * number and so sometimes we'll exhaust that limit. When this happens, we this * method will detect that and call our GobanCore.canvasAllocationErrorHandler * hook. On OGS we'll reload the page in that hook after logging the error. * * If string dimensions are used we'll use setAttribute, if numbers are used * we'll set the canvas .width and .height parameter. This is for device * scaling considerations when the given dimensions are scaled on HDPI devices. */ export declare function allocateCanvasOrError(width?: number | string, height?: number | string): HTMLCanvasElement; /** * Validates that a canvas was created successfully and a 2d context can be * allocated for it. If not, we call the GobanCore.canvasAllocationErrorHandler * hook. */ export declare function validateCanvas(canvas: HTMLCanvasElement | null, err?: Error, width?: number | string, height?: number | string): boolean; export declare function createDeviceScaledCanvas(width: number, height: number): HTMLCanvasElement; export declare function resizeDeviceScaledCanvas(canvas: HTMLCanvasElement, width: number, height: number): HTMLCanvasElement; export declare function deviceCanvasScalingRatio(): number; /** Returns `{x,y}` of the event relative to the event target */ export declare function getRelativeEventPosition(event: TouchEvent | MouseEvent, target?: HTMLElement): { x: number; y: number; }; export declare function elementOffset(element: HTMLElement): { top: number; left: number; };