pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 6.31 kB
Source Map (JSON)
{"version":3,"file":"FederatedPointerEvent.mjs","sources":["../../src/events/FederatedPointerEvent.ts"],"sourcesContent":["import { FederatedMouseEvent } from './FederatedMouseEvent';\n\n/**\n * A specialized event class for pointer interactions in PixiJS applications.\n * Extends {@link FederatedMouseEvent} to provide advanced pointer-specific features\n * while maintaining compatibility with the DOM PointerEvent interface.\n *\n * Key features:\n * - Supports multi-touch interactions\n * - Provides pressure sensitivity\n * - Handles stylus input\n * - Tracks pointer dimensions\n * - Supports tilt detection\n * @example\n * ```ts\n * // Basic pointer event handling\n * sprite.on('pointerdown', (event: FederatedPointerEvent) => {\n * // Access pointer information\n * console.log('Pointer ID:', event.pointerId);\n * console.log('Pointer Type:', event.pointerType);\n * console.log('Is Primary:', event.isPrimary);\n *\n * // Get pressure and tilt data\n * console.log('Pressure:', event.pressure);\n * console.log('Tilt:', event.tiltX, event.tiltY);\n *\n * // Access contact geometry\n * console.log('Size:', event.width, event.height);\n * });\n *\n * // Handle stylus-specific features\n * sprite.on('pointermove', (event: FederatedPointerEvent) => {\n * if (event.pointerType === 'pen') {\n * // Handle stylus tilt\n * const tiltAngle = Math.atan2(event.tiltY, event.tiltX);\n * console.log('Tilt angle:', tiltAngle);\n *\n * // Use barrel button pressure\n * console.log('Tangential pressure:', event.tangentialPressure);\n * }\n * });\n * ```\n * @see {@link FederatedMouseEvent} For base mouse event functionality\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent} DOM PointerEvent Interface\n * @see {@link EventSystem} For the event management system\n * @category events\n * @standard\n */\nexport class FederatedPointerEvent extends FederatedMouseEvent implements PointerEvent\n{\n /**\n * The unique identifier of the pointer.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId}\n */\n public pointerId: number;\n\n /**\n * The width of the pointer's contact along the x-axis, measured in CSS pixels.\n * radiusX of TouchEvents will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width\n */\n public width = 0;\n\n /**\n * The angle in radians of a pointer or stylus measuring the vertical angle between\n * the device's surface to the pointer or stylus.\n * A stylus at 0 degrees would be directly parallel whereas at π/2 degrees it would be perpendicular.\n * @see https://developer.mozilla.org/docs/Web/API/PointerEvent/altitudeAngle)\n */\n public altitudeAngle: number;\n\n /**\n * The angle in radians of a pointer or stylus measuring an arc from the X axis of the device to\n * the pointer or stylus projected onto the screen's plane.\n * A stylus at 0 degrees would be pointing to the \"0 o'clock\" whereas at π/2 degrees it would be pointing at \"6 o'clock\".\n * @see https://developer.mozilla.org/docs/Web/API/PointerEvent/azimuthAngle)\n */\n public azimuthAngle: number;\n\n /**\n * The height of the pointer's contact along the y-axis, measured in CSS pixels.\n * radiusY of TouchEvents will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height\n */\n public height = 0;\n\n /**\n * Indicates whether or not the pointer device that created the event is the primary pointer.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary\n */\n public isPrimary = false;\n\n /**\n * The type of pointer that triggered the event.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType\n */\n public pointerType: string;\n\n /**\n * Pressure applied by the pointing device during the event.\n *s\n * A Touch's force property will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure\n */\n public pressure: number;\n\n /**\n * Barrel pressure on a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n public tangentialPressure: number;\n\n /**\n * The angle, in degrees, between the pointer device and the screen.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX\n */\n public tiltX: number;\n\n /**\n * The angle, in degrees, between the pointer device and the screen.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY\n */\n public tiltY: number;\n\n /**\n * Twist of a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n public twist: number;\n\n /** This is the number of clicks that occurs in 200ms/click of each other. */\n public detail: number;\n\n /**\n * Only included for completeness for now\n * @ignore\n */\n public getCoalescedEvents(): PointerEvent[]\n {\n if (this.type === 'pointermove' || this.type === 'mousemove' || this.type === 'touchmove')\n {\n return [this];\n }\n\n return [];\n }\n\n /**\n * Only included for completeness for now\n * @ignore\n */\n public getPredictedEvents(): PointerEvent[]\n {\n throw new Error('getPredictedEvents is not supported!');\n }\n}\n"],"names":[],"mappings":";;;AAgDO,MAAM,8BAA8B,mBAC3C,CAAA;AAAA,EADO,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CAAA;AAaH;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,KAAQ,GAAA,CAAA,CAAA;AAuBf;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,MAAS,GAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAO,SAAY,GAAA,KAAA,CAAA;AAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+CZ,kBACP,GAAA;AACI,IAAI,IAAA,IAAA,CAAK,SAAS,aAAiB,IAAA,IAAA,CAAK,SAAS,WAAe,IAAA,IAAA,CAAK,SAAS,WAC9E,EAAA;AACI,MAAA,OAAO,CAAC,IAAI,CAAA,CAAA;AAAA,KAChB;AAEA,IAAA,OAAO,EAAC,CAAA;AAAA,GACZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,kBACP,GAAA;AACI,IAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA,CAAA;AAAA,GAC1D;AACJ;;;;"}