diff --git a/packages/interaction/package.json b/packages/interaction/package.json index e9b74ed..edbf859 100644 --- a/packages/interaction/package.json +++ b/packages/interaction/package.json @@ -31,6 +31,7 @@ "@pixi/core": "^5.0.0-rc.3", "@pixi/display": "^5.0.0-rc.3", "@pixi/math": "^5.0.0-rc.3", + "@pixi/settings": "^5.0.0-rc.3", "@pixi/ticker": "^5.0.0-rc.3", "@pixi/utils": "^5.0.0-rc.3" }, diff --git a/packages/interaction/package.json b/packages/interaction/package.json index e9b74ed..edbf859 100644 --- a/packages/interaction/package.json +++ b/packages/interaction/package.json @@ -31,6 +31,7 @@ "@pixi/core": "^5.0.0-rc.3", "@pixi/display": "^5.0.0-rc.3", "@pixi/math": "^5.0.0-rc.3", + "@pixi/settings": "^5.0.0-rc.3", "@pixi/ticker": "^5.0.0-rc.3", "@pixi/utils": "^5.0.0-rc.3" }, diff --git a/packages/interaction/src/InteractionManager.js b/packages/interaction/src/InteractionManager.js index 0df6545..c6d4a2c 100644 --- a/packages/interaction/src/InteractionManager.js +++ b/packages/interaction/src/InteractionManager.js @@ -1,10 +1,11 @@ import { Ticker, UPDATE_PRIORITY } from '@pixi/ticker'; import { Point } from '@pixi/math'; import { DisplayObject } from '@pixi/display'; +import { EventEmitter } from '@pixi/utils'; +import { settings } from '@pixi/settings'; import InteractionData from './InteractionData'; import InteractionEvent from './InteractionEvent'; import InteractionTrackingData from './InteractionTrackingData'; -import { EventEmitter } from '@pixi/utils'; import interactiveTarget from './interactiveTarget'; // Mix interactiveTarget into DisplayObject.prototype, @@ -157,13 +158,14 @@ this.supportsTouchEvents = 'ontouchstart' in window; /** - * Does the device support pointer events + * Should the PointEvent API be used for 'mouse' and 'pointer' events. + * If not, MouseEvents will be used instead. * https://www.w3.org/Submission/pointer-events/ * * @readonly * @member {boolean} */ - this.supportsPointerEvents = !!window.PointerEvent; + this.usePointerEventAPI = settings.USE_POINTER_EVENT_API && !!window.PointerEvent; // this will make it so that you don't have to call bind all the time @@ -342,15 +344,26 @@ /** * Fired when a pointer device button is pressed on the display object. * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerdown event + * is not fired when a button is pressed whilst another is already held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerdown to be fired for in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. + * * @event PIXI.interaction.InteractionManager#pointerdown * @param {PIXI.interaction.InteractionEvent} event - Interaction event */ /** - * Fired when a pointer device button is released over the display object. - * Not always fired when some buttons are held down while others are released. In those cases, - * use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and - * [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead. + * Fired when a pointer device button is released on the display object. + * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerup event + * is not fired when a button is released whilst another is still held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerup to be fired in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. * * @event PIXI.interaction.InteractionManager#pointerup * @param {PIXI.interaction.InteractionEvent} event - Interaction event @@ -715,7 +728,7 @@ this.interactionDOMElement.style['-ms-content-zooming'] = 'none'; this.interactionDOMElement.style['-ms-touch-action'] = 'none'; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = 'none'; } @@ -724,7 +737,7 @@ * These events are added first, so that if pointer events are normalized, they are fired * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd */ - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.addEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true); @@ -778,12 +791,12 @@ this.interactionDOMElement.style['-ms-content-zooming'] = ''; this.interactionDOMElement.style['-ms-touch-action'] = ''; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = ''; } - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.removeEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true); @@ -1780,7 +1793,7 @@ } } // apparently PointerEvent subclasses MouseEvent, so yay - else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) + else if (event instanceof MouseEvent && (!this.usePointerEventAPI || !(event instanceof window.PointerEvent))) { if (typeof event.isPrimary === 'undefined') event.isPrimary = true; if (typeof event.width === 'undefined') event.width = 1; diff --git a/packages/interaction/package.json b/packages/interaction/package.json index e9b74ed..edbf859 100644 --- a/packages/interaction/package.json +++ b/packages/interaction/package.json @@ -31,6 +31,7 @@ "@pixi/core": "^5.0.0-rc.3", "@pixi/display": "^5.0.0-rc.3", "@pixi/math": "^5.0.0-rc.3", + "@pixi/settings": "^5.0.0-rc.3", "@pixi/ticker": "^5.0.0-rc.3", "@pixi/utils": "^5.0.0-rc.3" }, diff --git a/packages/interaction/src/InteractionManager.js b/packages/interaction/src/InteractionManager.js index 0df6545..c6d4a2c 100644 --- a/packages/interaction/src/InteractionManager.js +++ b/packages/interaction/src/InteractionManager.js @@ -1,10 +1,11 @@ import { Ticker, UPDATE_PRIORITY } from '@pixi/ticker'; import { Point } from '@pixi/math'; import { DisplayObject } from '@pixi/display'; +import { EventEmitter } from '@pixi/utils'; +import { settings } from '@pixi/settings'; import InteractionData from './InteractionData'; import InteractionEvent from './InteractionEvent'; import InteractionTrackingData from './InteractionTrackingData'; -import { EventEmitter } from '@pixi/utils'; import interactiveTarget from './interactiveTarget'; // Mix interactiveTarget into DisplayObject.prototype, @@ -157,13 +158,14 @@ this.supportsTouchEvents = 'ontouchstart' in window; /** - * Does the device support pointer events + * Should the PointEvent API be used for 'mouse' and 'pointer' events. + * If not, MouseEvents will be used instead. * https://www.w3.org/Submission/pointer-events/ * * @readonly * @member {boolean} */ - this.supportsPointerEvents = !!window.PointerEvent; + this.usePointerEventAPI = settings.USE_POINTER_EVENT_API && !!window.PointerEvent; // this will make it so that you don't have to call bind all the time @@ -342,15 +344,26 @@ /** * Fired when a pointer device button is pressed on the display object. * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerdown event + * is not fired when a button is pressed whilst another is already held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerdown to be fired for in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. + * * @event PIXI.interaction.InteractionManager#pointerdown * @param {PIXI.interaction.InteractionEvent} event - Interaction event */ /** - * Fired when a pointer device button is released over the display object. - * Not always fired when some buttons are held down while others are released. In those cases, - * use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and - * [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead. + * Fired when a pointer device button is released on the display object. + * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerup event + * is not fired when a button is released whilst another is still held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerup to be fired in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. * * @event PIXI.interaction.InteractionManager#pointerup * @param {PIXI.interaction.InteractionEvent} event - Interaction event @@ -715,7 +728,7 @@ this.interactionDOMElement.style['-ms-content-zooming'] = 'none'; this.interactionDOMElement.style['-ms-touch-action'] = 'none'; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = 'none'; } @@ -724,7 +737,7 @@ * These events are added first, so that if pointer events are normalized, they are fired * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd */ - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.addEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true); @@ -778,12 +791,12 @@ this.interactionDOMElement.style['-ms-content-zooming'] = ''; this.interactionDOMElement.style['-ms-touch-action'] = ''; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = ''; } - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.removeEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true); @@ -1780,7 +1793,7 @@ } } // apparently PointerEvent subclasses MouseEvent, so yay - else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) + else if (event instanceof MouseEvent && (!this.usePointerEventAPI || !(event instanceof window.PointerEvent))) { if (typeof event.isPrimary === 'undefined') event.isPrimary = true; if (typeof event.width === 'undefined') event.width = 1; diff --git a/packages/interaction/src/index.js b/packages/interaction/src/index.js index 9e7df89..918e4c4 100644 --- a/packages/interaction/src/index.js +++ b/packages/interaction/src/index.js @@ -5,6 +5,8 @@ * See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}. * @namespace PIXI.interaction */ +import './settings'; + export { default as InteractionData } from './InteractionData'; export { default as InteractionManager } from './InteractionManager'; export { default as interactiveTarget } from './interactiveTarget'; diff --git a/packages/interaction/package.json b/packages/interaction/package.json index e9b74ed..edbf859 100644 --- a/packages/interaction/package.json +++ b/packages/interaction/package.json @@ -31,6 +31,7 @@ "@pixi/core": "^5.0.0-rc.3", "@pixi/display": "^5.0.0-rc.3", "@pixi/math": "^5.0.0-rc.3", + "@pixi/settings": "^5.0.0-rc.3", "@pixi/ticker": "^5.0.0-rc.3", "@pixi/utils": "^5.0.0-rc.3" }, diff --git a/packages/interaction/src/InteractionManager.js b/packages/interaction/src/InteractionManager.js index 0df6545..c6d4a2c 100644 --- a/packages/interaction/src/InteractionManager.js +++ b/packages/interaction/src/InteractionManager.js @@ -1,10 +1,11 @@ import { Ticker, UPDATE_PRIORITY } from '@pixi/ticker'; import { Point } from '@pixi/math'; import { DisplayObject } from '@pixi/display'; +import { EventEmitter } from '@pixi/utils'; +import { settings } from '@pixi/settings'; import InteractionData from './InteractionData'; import InteractionEvent from './InteractionEvent'; import InteractionTrackingData from './InteractionTrackingData'; -import { EventEmitter } from '@pixi/utils'; import interactiveTarget from './interactiveTarget'; // Mix interactiveTarget into DisplayObject.prototype, @@ -157,13 +158,14 @@ this.supportsTouchEvents = 'ontouchstart' in window; /** - * Does the device support pointer events + * Should the PointEvent API be used for 'mouse' and 'pointer' events. + * If not, MouseEvents will be used instead. * https://www.w3.org/Submission/pointer-events/ * * @readonly * @member {boolean} */ - this.supportsPointerEvents = !!window.PointerEvent; + this.usePointerEventAPI = settings.USE_POINTER_EVENT_API && !!window.PointerEvent; // this will make it so that you don't have to call bind all the time @@ -342,15 +344,26 @@ /** * Fired when a pointer device button is pressed on the display object. * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerdown event + * is not fired when a button is pressed whilst another is already held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerdown to be fired for in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. + * * @event PIXI.interaction.InteractionManager#pointerdown * @param {PIXI.interaction.InteractionEvent} event - Interaction event */ /** - * Fired when a pointer device button is released over the display object. - * Not always fired when some buttons are held down while others are released. In those cases, - * use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and - * [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead. + * Fired when a pointer device button is released on the display object. + * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerup event + * is not fired when a button is released whilst another is still held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerup to be fired in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. * * @event PIXI.interaction.InteractionManager#pointerup * @param {PIXI.interaction.InteractionEvent} event - Interaction event @@ -715,7 +728,7 @@ this.interactionDOMElement.style['-ms-content-zooming'] = 'none'; this.interactionDOMElement.style['-ms-touch-action'] = 'none'; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = 'none'; } @@ -724,7 +737,7 @@ * These events are added first, so that if pointer events are normalized, they are fired * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd */ - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.addEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true); @@ -778,12 +791,12 @@ this.interactionDOMElement.style['-ms-content-zooming'] = ''; this.interactionDOMElement.style['-ms-touch-action'] = ''; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = ''; } - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.removeEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true); @@ -1780,7 +1793,7 @@ } } // apparently PointerEvent subclasses MouseEvent, so yay - else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) + else if (event instanceof MouseEvent && (!this.usePointerEventAPI || !(event instanceof window.PointerEvent))) { if (typeof event.isPrimary === 'undefined') event.isPrimary = true; if (typeof event.width === 'undefined') event.width = 1; diff --git a/packages/interaction/src/index.js b/packages/interaction/src/index.js index 9e7df89..918e4c4 100644 --- a/packages/interaction/src/index.js +++ b/packages/interaction/src/index.js @@ -5,6 +5,8 @@ * See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}. * @namespace PIXI.interaction */ +import './settings'; + export { default as InteractionData } from './InteractionData'; export { default as InteractionManager } from './InteractionManager'; export { default as interactiveTarget } from './interactiveTarget'; diff --git a/packages/interaction/src/settings.js b/packages/interaction/src/settings.js new file mode 100644 index 0000000..834cb6f --- /dev/null +++ b/packages/interaction/src/settings.js @@ -0,0 +1,24 @@ +import { settings } from '@pixi/settings'; + +/** + * Should PixiJS use the PointerEvent API instead of MouseEvent API when generating interaction events. + * This setting effects 'mouse' events only, not 'touch' events, which always use the TouchEvent API. + * Advantages to this are using the modern api with the extra properties it comes with, such as 'pressure'. + * It also allows 'touch' to work on Surface laptops that don't otherwise report as supporting touch. + * Disadvantages are 'quirks' to how a PointerEvent works for mice, such a down and up events not being + * fired if other buttons are already in a down state. + * Whether this is enabled or disabled, you can still listen to normalised events such as 'pointerdown', + * 'pointerup' - it's just that if it is disabled you will not be getting true PointerEvent behaviour. + * + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent + * + * @static + * @constant + * @name USE_POINTER_EVENT_API + * @memberof PIXI.settings + * @type {boolean} + * @default false + */ +settings.USE_POINTER_EVENT_API = true; + +export { settings }; diff --git a/packages/interaction/package.json b/packages/interaction/package.json index e9b74ed..edbf859 100644 --- a/packages/interaction/package.json +++ b/packages/interaction/package.json @@ -31,6 +31,7 @@ "@pixi/core": "^5.0.0-rc.3", "@pixi/display": "^5.0.0-rc.3", "@pixi/math": "^5.0.0-rc.3", + "@pixi/settings": "^5.0.0-rc.3", "@pixi/ticker": "^5.0.0-rc.3", "@pixi/utils": "^5.0.0-rc.3" }, diff --git a/packages/interaction/src/InteractionManager.js b/packages/interaction/src/InteractionManager.js index 0df6545..c6d4a2c 100644 --- a/packages/interaction/src/InteractionManager.js +++ b/packages/interaction/src/InteractionManager.js @@ -1,10 +1,11 @@ import { Ticker, UPDATE_PRIORITY } from '@pixi/ticker'; import { Point } from '@pixi/math'; import { DisplayObject } from '@pixi/display'; +import { EventEmitter } from '@pixi/utils'; +import { settings } from '@pixi/settings'; import InteractionData from './InteractionData'; import InteractionEvent from './InteractionEvent'; import InteractionTrackingData from './InteractionTrackingData'; -import { EventEmitter } from '@pixi/utils'; import interactiveTarget from './interactiveTarget'; // Mix interactiveTarget into DisplayObject.prototype, @@ -157,13 +158,14 @@ this.supportsTouchEvents = 'ontouchstart' in window; /** - * Does the device support pointer events + * Should the PointEvent API be used for 'mouse' and 'pointer' events. + * If not, MouseEvents will be used instead. * https://www.w3.org/Submission/pointer-events/ * * @readonly * @member {boolean} */ - this.supportsPointerEvents = !!window.PointerEvent; + this.usePointerEventAPI = settings.USE_POINTER_EVENT_API && !!window.PointerEvent; // this will make it so that you don't have to call bind all the time @@ -342,15 +344,26 @@ /** * Fired when a pointer device button is pressed on the display object. * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerdown event + * is not fired when a button is pressed whilst another is already held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerdown to be fired for in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. + * * @event PIXI.interaction.InteractionManager#pointerdown * @param {PIXI.interaction.InteractionEvent} event - Interaction event */ /** - * Fired when a pointer device button is released over the display object. - * Not always fired when some buttons are held down while others are released. In those cases, - * use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and - * [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead. + * Fired when a pointer device button is released on the display object. + * + * If {@link PIXI.settings.USE_POINTER_EVENT_API} is true and supported, then a pointerup event + * is not fired when a button is released whilst another is still held down. + * According to the pointer spec, a [pointermove]{@link PIXI.interaction.InteractionManager#event:pointermove} + * event is emitted in this scenario, with the 'buttons' property updated. + * If you wish for pointerup to be fired in this scenario, then change + * {@link PIXI.settings.USE_POINTER_EVENT_API} to false. * * @event PIXI.interaction.InteractionManager#pointerup * @param {PIXI.interaction.InteractionEvent} event - Interaction event @@ -715,7 +728,7 @@ this.interactionDOMElement.style['-ms-content-zooming'] = 'none'; this.interactionDOMElement.style['-ms-touch-action'] = 'none'; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = 'none'; } @@ -724,7 +737,7 @@ * These events are added first, so that if pointer events are normalized, they are fired * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd */ - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.addEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true); @@ -778,12 +791,12 @@ this.interactionDOMElement.style['-ms-content-zooming'] = ''; this.interactionDOMElement.style['-ms-touch-action'] = ''; } - else if (this.supportsPointerEvents) + else if (window.PointerEvent) { this.interactionDOMElement.style['touch-action'] = ''; } - if (this.supportsPointerEvents) + if (this.usePointerEventAPI) { window.document.removeEventListener('pointermove', this.onPointerMove, true); this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true); @@ -1780,7 +1793,7 @@ } } // apparently PointerEvent subclasses MouseEvent, so yay - else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) + else if (event instanceof MouseEvent && (!this.usePointerEventAPI || !(event instanceof window.PointerEvent))) { if (typeof event.isPrimary === 'undefined') event.isPrimary = true; if (typeof event.width === 'undefined') event.width = 1; diff --git a/packages/interaction/src/index.js b/packages/interaction/src/index.js index 9e7df89..918e4c4 100644 --- a/packages/interaction/src/index.js +++ b/packages/interaction/src/index.js @@ -5,6 +5,8 @@ * See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}. * @namespace PIXI.interaction */ +import './settings'; + export { default as InteractionData } from './InteractionData'; export { default as InteractionManager } from './InteractionManager'; export { default as interactiveTarget } from './interactiveTarget'; diff --git a/packages/interaction/src/settings.js b/packages/interaction/src/settings.js new file mode 100644 index 0000000..834cb6f --- /dev/null +++ b/packages/interaction/src/settings.js @@ -0,0 +1,24 @@ +import { settings } from '@pixi/settings'; + +/** + * Should PixiJS use the PointerEvent API instead of MouseEvent API when generating interaction events. + * This setting effects 'mouse' events only, not 'touch' events, which always use the TouchEvent API. + * Advantages to this are using the modern api with the extra properties it comes with, such as 'pressure'. + * It also allows 'touch' to work on Surface laptops that don't otherwise report as supporting touch. + * Disadvantages are 'quirks' to how a PointerEvent works for mice, such a down and up events not being + * fired if other buttons are already in a down state. + * Whether this is enabled or disabled, you can still listen to normalised events such as 'pointerdown', + * 'pointerup' - it's just that if it is disabled you will not be getting true PointerEvent behaviour. + * + * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent + * + * @static + * @constant + * @name USE_POINTER_EVENT_API + * @memberof PIXI.settings + * @type {boolean} + * @default false + */ +settings.USE_POINTER_EVENT_API = true; + +export { settings }; diff --git a/packages/interaction/test/InteractionManager.js b/packages/interaction/test/InteractionManager.js index 0671e97..06d8e17 100644 --- a/packages/interaction/test/InteractionManager.js +++ b/packages/interaction/test/InteractionManager.js @@ -250,7 +250,7 @@ const removeSpy = sinon.spy(window.document, 'removeEventListener'); manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = true; + manager.usePointerEventAPI = true; manager.addEvents(); @@ -273,7 +273,7 @@ const removeSpy = sinon.spy(window, 'removeEventListener'); manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = true; + manager.usePointerEventAPI = true; manager.addEvents(); @@ -297,7 +297,7 @@ const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; manager.interactionDOMElement = element; - manager.supportsPointerEvents = true; + manager.usePointerEventAPI = true; manager.supportsTouchEvents = true; manager.addEvents(); @@ -331,7 +331,7 @@ const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; manager.interactionDOMElement = element; - manager.supportsPointerEvents = true; + manager.usePointerEventAPI = true; manager.supportsTouchEvents = false; manager.addEvents(); @@ -356,7 +356,7 @@ const removeSpy = sinon.spy(window.document, 'removeEventListener'); manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = false; + manager.usePointerEventAPI = false; manager.addEvents(); @@ -379,7 +379,7 @@ const removeSpy = sinon.spy(window, 'removeEventListener'); manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = false; + manager.usePointerEventAPI = false; manager.addEvents(); @@ -401,7 +401,7 @@ const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; manager.interactionDOMElement = element; - manager.supportsPointerEvents = false; + manager.usePointerEventAPI = false; manager.supportsTouchEvents = false; manager.addEvents(); @@ -425,7 +425,7 @@ const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; manager.interactionDOMElement = element; - manager.supportsPointerEvents = false; + manager.usePointerEventAPI = false; manager.supportsTouchEvents = true; manager.addEvents(); @@ -449,7 +449,7 @@ const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; manager.interactionDOMElement = element; - manager.supportsPointerEvents = true; + manager.usePointerEventAPI = true; manager.supportsTouchEvents = true; manager.addEvents();