UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

91 lines (90 loc) 4.44 kB
import { FocusType } from '../core/FocusType.js'; import { PointerEvent } from './PointerEvent.js'; import { Widget } from '../widgets/Widget.js'; import type { SourcePointer } from '../drivers/SourcePointer.js'; /** * The scrolling mode that determines how the {@link PointerWheelEvent#deltaX}, * {@link PointerWheelEvent#deltaY} and {@link PointerWheelEvent#deltaZ} values * are interpreted. * * @category Event */ export declare enum PointerWheelMode { /** In this mode, delta values are measured in pixels. */ Pixel = 0, /** * In this mode, delta values are measured in line heights. The height of a * line is supplied as an argument to the * {@link PointerWheelEvent#getDeltaPixels} method. */ Line = 1, /** * In this mode, delta values are measured in {@link Widget} dimensions, * minus {@link PointerWheelEvent.PageLinesError | a few lines} or * {@link PointerWheelEvent.PagePercentError | a percentage of the dimensions}, * whichever is smaller. Both line height and dimensions are supplied as * arguments to the {@link PointerWheelEvent#getDeltaPixels} method. */ Page = 2 } /** * Convert DOM WheelEvent.deltaMode to {@link PointerWheelMode}, or null if the * DOM delta mode is unknown. * * @category Event */ export declare function parseDOMDeltaMode(domDeltaMode: number): PointerWheelMode | null; /** * A pointer wheel {@link PointerEvent}. * * Has a focus type of {@link FocusType.Pointer} and does not need focus. * * @category Event */ export declare class PointerWheelEvent extends PointerEvent { static readonly type = "pointer-wheel"; readonly type: typeof PointerWheelEvent.type; readonly focusType: FocusType.Pointer; /** * Wheel event horizontal scroll amount. Not an integer. The value's * interpretation depends on {@link PointerWheelEvent#deltaMode}. */ readonly deltaX: number; /** * Wheel event vertical scroll amount. Not an integer. The value's * interpretation depends on {@link PointerWheelEvent#deltaMode}. */ readonly deltaY: number; /** * Wheel event depth scroll amount. Not an integer. The value's * interpretation depends on {@link PointerWheelEvent#deltaMode}. */ readonly deltaZ: number; /** * The mode of the delta values; how the delta values should be * interpreted. See {@link PointerWheelMode} */ readonly deltaMode: PointerWheelMode; /** Was this wheel event created from a pointer drag? */ readonly fromDrag: boolean; /** The amount of lines to remove from a page scroll */ static readonly PageLinesError = 3; /** The percentage of a page to remove from a page scroll */ static readonly PagePercentError = 0.1; constructor(x: number, y: number, deltaX: number, deltaY: number, deltaZ: number, deltaMode: PointerWheelMode, fromDrag: boolean, shift: boolean, ctrl: boolean, alt: boolean, source: SourcePointer | null, target?: Widget | null); correctOffset(xOffset: number, yOffset: number): PointerWheelEvent; cloneWithTarget(target: Widget | null): PointerWheelEvent; /** * Get the scroll delta in pixels, even if the * {@link PointerWheelEvent#deltaMode} is not * {@link PointerWheelMode.Pixel}. * * @param forceLimit - Should the delta be limited by {@link PointerWheelEvent.PageLinesError} and {@link PointerWheelEvent.PagePercentError}, if {@link PointerWheelEvent#deltaMode} is not {@link PointerWheelMode.Page}? * @param lineHeight - The full height (line height with spacing) of a line, used for page {@link PointerWheelEvent#deltaMode}, or for limiting the delta * @param containerWidth - The width of the container, used for page {@link PointerWheelEvent#deltaMode}, or for limiting the delta * @param containerHeight - The height of the container, used for page {@link PointerWheelEvent#deltaMode}, or for limiting the delta * @param containerDepth - The depth of the container, used for page {@link PointerWheelEvent#deltaMode}, or for limiting the delta. Only used for custom containers/widgets with a Z-axis * @returns Returns a 3-tuple containing the x, y and z components, repectively, of the wheel event in pixels. */ getDeltaPixels(forceLimit: boolean, lineHeight: number, containerWidth: number, containerHeight: number, containerDepth?: number): [x: number, y: number, z: number]; }