From 5283d61224e30115dd3bb808bb166108503e45ec Mon Sep 17 00:00:00 2001 From: busti Date: Sun, 11 Mar 2018 15:16:50 +0100 Subject: [PATCH 01/10] Added the PointerEvent class and pointerevent Functions to the according DOM elements. --- src/main/scala/org/scalajs/dom/package.scala | 1 + src/main/scala/org/scalajs/dom/raw/Html.scala | 156 +++++++++++++++ src/main/scala/org/scalajs/dom/raw/lib.scala | 178 ++++++++++++++++++ 3 files changed, 335 insertions(+) diff --git a/src/main/scala/org/scalajs/dom/package.scala b/src/main/scala/org/scalajs/dom/package.scala index 817ab97d1..2987a56cb 100644 --- a/src/main/scala/org/scalajs/dom/package.scala +++ b/src/main/scala/org/scalajs/dom/package.scala @@ -116,6 +116,7 @@ package object dom { type MessagePort = raw.MessagePort type ModifierKeyEvent = raw.ModifierKeyEvent type MouseEvent = raw.MouseEvent + type PointerEvent = raw.PointerEvent @deprecated("Obsolete.", "WHATWG DOM") type MutationEvent = raw.MutationEvent @deprecated("Obsolete.", "WHATWG DOM") diff --git a/src/main/scala/org/scalajs/dom/raw/Html.scala b/src/main/scala/org/scalajs/dom/raw/Html.scala index 358ee2480..c5797dd33 100644 --- a/src/main/scala/org/scalajs/dom/raw/Html.scala +++ b/src/main/scala/org/scalajs/dom/raw/Html.scala @@ -546,6 +546,84 @@ abstract class HTMLDocument extends Document { var oncanplaythrough: js.Function1[Event, _] = js.native var onstoragecommit: js.Function1[StorageEvent, _] = js.native + + /** + * fired when a pointing device is moved into an element's hit test boundaries. + * + * MDN + */ + var onpointerover: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointing device is moved into the hit test boundaries of an element + * or one of its descendants, including as a result of a pointerdown event + * from a device that does not support hover (see pointerdown). + * + * MDN + */ + var onpointerenter: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer becomes active. + * + * MDN + */ + var onpointerdown: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer changes coordinates. + * + * MDN + */ + var onpointermove: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer is no longer active. + * + * MDN + */ + var onpointerup: js.Function1[PointerEvent, _] = js.native + + /** + * a browser fires this event if it concludes the pointer will no longer be able + * to generate events (for example the related device is deactived). + * + * MDN + */ + var onpointercancel: js.Function1[PointerEvent, _] = js.native + + /** + * fired for several reasons including: pointing device is moved out of + * the hit test boundaries of an element; + * firing the pointerup event for a device that does not support hover (see pointerup); + * after firing the pointercancel event (see pointercancel); + * when a pen stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ + var onpointerout: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointing device is moved out of the hit test boundaries of an element. + * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ + var onpointerleave: js.Function1[PointerEvent, _] = js.native + + /** + * fired when an element receives pointer capture. + * + * MDN + */ + var gotpointercapture: js.Function1[PointerEvent, _] = js.native + + /** + * Fired after pointer capture is released for a pointer. + * + * MDN + */ + var lostpointercapture: js.Function1[PointerEvent, _] = js.native } /** @@ -4117,6 +4195,84 @@ abstract class HTMLElement extends Element { * is an HTMLElement) that we are getting an HTMLDocument here. */ override def ownerDocument: HTMLDocument = js.native + + /** + * fired when a pointing device is moved into an element's hit test boundaries. + * + * MDN + */ + var onpointerover: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointing device is moved into the hit test boundaries of an element + * or one of its descendants, including as a result of a pointerdown event + * from a device that does not support hover (see pointerdown). + * + * MDN + */ + var onpointerenter: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer becomes active. + * + * MDN + */ + var onpointerdown: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer changes coordinates. + * + * MDN + */ + var onpointermove: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer is no longer active. + * + * MDN + */ + var onpointerup: js.Function1[PointerEvent, _] = js.native + + /** + * a browser fires this event if it concludes the pointer will no longer be able + * to generate events (for example the related device is deactived). + * + * MDN + */ + var onpointercancel: js.Function1[PointerEvent, _] = js.native + + /** + * fired for several reasons including: pointing device is moved out of + * the hit test boundaries of an element; + * firing the pointerup event for a device that does not support hover (see pointerup); + * after firing the pointercancel event (see pointercancel); + * when a pen stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ + var onpointerout: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointing device is moved out of the hit test boundaries of an element. + * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ + var onpointerleave: js.Function1[PointerEvent, _] = js.native + + /** + * fired when an element receives pointer capture. + * + * MDN + */ + var gotpointercapture: js.Function1[PointerEvent, _] = js.native + + /** + * Fired after pointer capture is released for a pointer. + * + * MDN + */ + var lostpointercapture: js.Function1[PointerEvent, _] = js.native } /** diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index a9f32fa96..a5358ff59 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1443,6 +1443,106 @@ class MouseEvent extends UIEvent with ModifierKeyEvent { def getModifierState(keyArg: String): Boolean = js.native } +/** + * Most of today's web content assumes the user's pointing device will be a mouse. + * However, since many devices support other types of pointing input devices, + * such as pen/stylus and touch surfaces, extensions to the existing pointing device event models + * are needed and pointer events address that need. + * + * Pointer events are DOM events that are fired for a pointing device. + * They are designed to create a single DOM event model to handle pointing input devices such as a mouse, + * pen/stylus or touch (such as one or more fingers). + * The pointer is a hardware-agnostic device that can target a specific set of screen coordinates. + * Having a single event model for pointers can simplify creating Web sites and applications + * and provide a good user experience regardless of the user's hardware. + * However, for scenarios when device-specific handling is desired, + * pointer events defines a property to inspect the device type which produced the event. + * + * The events needed to handle generic pointer input are analogous to mouse events + * (mousedown/pointerdown, mousemove/pointermove, etc.). + * Consequently, pointer event types are intentionally similar to mouse event types. + * Additionally, a pointer event contains the usual properties present in mouse events + * (client coordinates, target element, button states, etc.) + * in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. + * In fact, the PointerEvent interface inherits all of the MouseEvent's properties thus facilitating + * migrating content from mouse events to pointer events. + */ +@js.native +@JSGlobal +class PointerEvent extends MouseEvent { + /** + * A unique identifier for the pointer causing the event. + * + * MDN + */ + def pointerId: Int = js.native + + /** + * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. + * + * MDN + */ + def width: Double = js.native + + /** + * The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. + * + * MDN + */ + def height: Double = js.native + + /** + * The normalized pressure of the pointer input in the range of 0 to 1, + * where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. + * + * MDN + */ + def pressure: Double = js.native + + /** + * The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane and the + * plane containing both the transducer (e.g. pen stylus) axis and the Y axis. + * + * MDN + */ + def tiltX: Double = js.native + + /** + * The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane and the + * plane containing both the transducer (e.g. pen stylus) axis and the X axis. + * + * MDN + */ + def tiltY: Double = js.native + + /** + * Indicates the device type that caused the event (mouse, pen, touch, etc.) + * + * MDN + */ + def pointerType: String = js.native + + /** + * Indicates if the pointer represents the primary pointer of this pointer type. + * + * In some scenarios there may be multiple pointers (for example a device with both a touchscreen and a mouse) + * or a pointer supports multiple contact points (for example a touchscreen that supports multiple finger touches). + * The application can use the isPrimary property to identify a master pointer + * among the set of active pointers for each pointer type. + * If an application only wants to support a primary pointer, + * it can ignore all pointer events that are not primary. + * + * For mouse there is only one pointer, so it will always be the primary pointer. + * For touch input, a pointer is considered primary if the user touched the screen + * when there were no other active touches. + * For pen and stylus input, a pointer is considered primary if the user's pen + * initially contacted the screenwhen there were no other active pens contacting the screen. + * + * MDN + */ + def isPrimary: Boolean = js.native +} + /** * The TextMetrics interface represents the dimension of a text in the canvas, as * created by the CanvasRenderingContext2D.measureText() method. @@ -2374,6 +2474,84 @@ class Window * MDN */ def devicePixelRatio: Double = js.native + + /** + * fired when a pointing device is moved into an element's hit test boundaries. + * + * MDN + */ + var onpointerover: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointing device is moved into the hit test boundaries of an element + * or one of its descendants, including as a result of a pointerdown event + * from a device that does not support hover (see pointerdown). + * + * MDN + */ + var onpointerenter: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer becomes active. + * + * MDN + */ + var onpointerdown: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer changes coordinates. + * + * MDN + */ + var onpointermove: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointer is no longer active. + * + * MDN + */ + var onpointerup: js.Function1[PointerEvent, _] = js.native + + /** + * a browser fires this event if it concludes the pointer will no longer be able + * to generate events (for example the related device is deactived). + * + * MDN + */ + var onpointercancel: js.Function1[PointerEvent, _] = js.native + + /** + * fired for several reasons including: pointing device is moved out of + * the hit test boundaries of an element; + * firing the pointerup event for a device that does not support hover (see pointerup); + * after firing the pointercancel event (see pointercancel); + * when a pen stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ + var onpointerout: js.Function1[PointerEvent, _] = js.native + + /** + * fired when a pointing device is moved out of the hit test boundaries of an element. + * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ + var onpointerleave: js.Function1[PointerEvent, _] = js.native + + /** + * fired when an element receives pointer capture. + * + * MDN + */ + var gotpointercapture: js.Function1[PointerEvent, _] = js.native + + /** + * Fired after pointer capture is released for a pointer. + * + * MDN + */ + var lostpointercapture: js.Function1[PointerEvent, _] = js.native } /** From 34aa7c4a1cf5d69252b28b549612e54f2206b403 Mon Sep 17 00:00:00 2001 From: busti Date: Sun, 11 Mar 2018 16:07:58 +0100 Subject: [PATCH 02/10] Fixed comment formatting. --- src/main/scala/org/scalajs/dom/raw/Html.scala | 192 +++++++------- src/main/scala/org/scalajs/dom/raw/lib.scala | 238 +++++++++--------- 2 files changed, 215 insertions(+), 215 deletions(-) diff --git a/src/main/scala/org/scalajs/dom/raw/Html.scala b/src/main/scala/org/scalajs/dom/raw/Html.scala index c5797dd33..8c95fb5a4 100644 --- a/src/main/scala/org/scalajs/dom/raw/Html.scala +++ b/src/main/scala/org/scalajs/dom/raw/Html.scala @@ -548,81 +548,81 @@ abstract class HTMLDocument extends Document { var onstoragecommit: js.Function1[StorageEvent, _] = js.native /** - * fired when a pointing device is moved into an element's hit test boundaries. - * - * MDN - */ + * fired when a pointing device is moved into an element's hit test boundaries. + * + * MDN + */ var onpointerover: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointing device is moved into the hit test boundaries of an element - * or one of its descendants, including as a result of a pointerdown event - * from a device that does not support hover (see pointerdown). - * - * MDN - */ + * fired when a pointing device is moved into the hit test boundaries of an element + * or one of its descendants, including as a result of a pointerdown event + * from a device that does not support hover (see pointerdown). + * + * MDN + */ var onpointerenter: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer becomes active. - * - * MDN - */ + * fired when a pointer becomes active. + * + * MDN + */ var onpointerdown: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer changes coordinates. - * - * MDN - */ + * fired when a pointer changes coordinates. + * + * MDN + */ var onpointermove: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer is no longer active. - * - * MDN - */ + * fired when a pointer is no longer active. + * + * MDN + */ var onpointerup: js.Function1[PointerEvent, _] = js.native /** - * a browser fires this event if it concludes the pointer will no longer be able - * to generate events (for example the related device is deactived). - * - * MDN - */ + * a browser fires this event if it concludes the pointer will no longer be able + * to generate events (for example the related device is deactived). + * + * MDN + */ var onpointercancel: js.Function1[PointerEvent, _] = js.native /** - * fired for several reasons including: pointing device is moved out of - * the hit test boundaries of an element; - * firing the pointerup event for a device that does not support hover (see pointerup); - * after firing the pointercancel event (see pointercancel); - * when a pen stylus leaves the hover range detectable by the digitizer. - * - * MDN - */ + * fired for several reasons including: pointing device is moved out of + * the hit test boundaries of an element; + * firing the pointerup event for a device that does not support hover (see pointerup); + * after firing the pointercancel event (see pointercancel); + * when a pen stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ var onpointerout: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointing device is moved out of the hit test boundaries of an element. - * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. - * - * MDN - */ + * fired when a pointing device is moved out of the hit test boundaries of an element. + * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ var onpointerleave: js.Function1[PointerEvent, _] = js.native /** - * fired when an element receives pointer capture. - * - * MDN - */ + * fired when an element receives pointer capture. + * + * MDN + */ var gotpointercapture: js.Function1[PointerEvent, _] = js.native /** - * Fired after pointer capture is released for a pointer. - * - * MDN - */ + * Fired after pointer capture is released for a pointer. + * + * MDN + */ var lostpointercapture: js.Function1[PointerEvent, _] = js.native } @@ -4197,81 +4197,81 @@ abstract class HTMLElement extends Element { override def ownerDocument: HTMLDocument = js.native /** - * fired when a pointing device is moved into an element's hit test boundaries. - * - * MDN - */ + * fired when a pointing device is moved into an element's hit test boundaries. + * + * MDN + */ var onpointerover: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointing device is moved into the hit test boundaries of an element - * or one of its descendants, including as a result of a pointerdown event - * from a device that does not support hover (see pointerdown). - * - * MDN - */ + * fired when a pointing device is moved into the hit test boundaries of an element + * or one of its descendants, including as a result of a pointerdown event + * from a device that does not support hover (see pointerdown). + * + * MDN + */ var onpointerenter: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer becomes active. - * - * MDN - */ + * fired when a pointer becomes active. + * + * MDN + */ var onpointerdown: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer changes coordinates. - * - * MDN - */ + * fired when a pointer changes coordinates. + * + * MDN + */ var onpointermove: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer is no longer active. - * - * MDN - */ + * fired when a pointer is no longer active. + * + * MDN + */ var onpointerup: js.Function1[PointerEvent, _] = js.native /** - * a browser fires this event if it concludes the pointer will no longer be able - * to generate events (for example the related device is deactived). - * - * MDN - */ + * a browser fires this event if it concludes the pointer will no longer be able + * to generate events (for example the related device is deactived). + * + * MDN + */ var onpointercancel: js.Function1[PointerEvent, _] = js.native /** - * fired for several reasons including: pointing device is moved out of - * the hit test boundaries of an element; - * firing the pointerup event for a device that does not support hover (see pointerup); - * after firing the pointercancel event (see pointercancel); - * when a pen stylus leaves the hover range detectable by the digitizer. - * - * MDN - */ + * fired for several reasons including: pointing device is moved out of + * the hit test boundaries of an element; + * firing the pointerup event for a device that does not support hover (see pointerup); + * after firing the pointercancel event (see pointercancel); + * when a pen stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ var onpointerout: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointing device is moved out of the hit test boundaries of an element. - * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. - * - * MDN - */ + * fired when a pointing device is moved out of the hit test boundaries of an element. + * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ var onpointerleave: js.Function1[PointerEvent, _] = js.native /** - * fired when an element receives pointer capture. - * - * MDN - */ + * fired when an element receives pointer capture. + * + * MDN + */ var gotpointercapture: js.Function1[PointerEvent, _] = js.native /** - * Fired after pointer capture is released for a pointer. - * - * MDN - */ + * Fired after pointer capture is released for a pointer. + * + * MDN + */ var lostpointercapture: js.Function1[PointerEvent, _] = js.native } diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index a5358ff59..0008f6ee1 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1444,102 +1444,102 @@ class MouseEvent extends UIEvent with ModifierKeyEvent { } /** - * Most of today's web content assumes the user's pointing device will be a mouse. - * However, since many devices support other types of pointing input devices, - * such as pen/stylus and touch surfaces, extensions to the existing pointing device event models - * are needed and pointer events address that need. - * - * Pointer events are DOM events that are fired for a pointing device. - * They are designed to create a single DOM event model to handle pointing input devices such as a mouse, - * pen/stylus or touch (such as one or more fingers). - * The pointer is a hardware-agnostic device that can target a specific set of screen coordinates. - * Having a single event model for pointers can simplify creating Web sites and applications - * and provide a good user experience regardless of the user's hardware. - * However, for scenarios when device-specific handling is desired, - * pointer events defines a property to inspect the device type which produced the event. - * - * The events needed to handle generic pointer input are analogous to mouse events - * (mousedown/pointerdown, mousemove/pointermove, etc.). - * Consequently, pointer event types are intentionally similar to mouse event types. - * Additionally, a pointer event contains the usual properties present in mouse events - * (client coordinates, target element, button states, etc.) - * in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. - * In fact, the PointerEvent interface inherits all of the MouseEvent's properties thus facilitating - * migrating content from mouse events to pointer events. - */ + * Most of today's web content assumes the user's pointing device will be a mouse. + * However, since many devices support other types of pointing input devices, + * such as pen/stylus and touch surfaces, extensions to the existing pointing device event models + * are needed and pointer events address that need. + * + * Pointer events are DOM events that are fired for a pointing device. + * They are designed to create a single DOM event model to handle pointing input devices such as a mouse, + * pen/stylus or touch (such as one or more fingers). + * The pointer is a hardware-agnostic device that can target a specific set of screen coordinates. + * Having a single event model for pointers can simplify creating Web sites and applications + * and provide a good user experience regardless of the user's hardware. + * However, for scenarios when device-specific handling is desired, + * pointer events defines a property to inspect the device type which produced the event. + * + * The events needed to handle generic pointer input are analogous to mouse events + * (mousedown/pointerdown, mousemove/pointermove, etc.). + * Consequently, pointer event types are intentionally similar to mouse event types. + * Additionally, a pointer event contains the usual properties present in mouse events + * (client coordinates, target element, button states, etc.) + * in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. + * In fact, the PointerEvent interface inherits all of the MouseEvent's properties thus facilitating + * migrating content from mouse events to pointer events. + */ @js.native @JSGlobal class PointerEvent extends MouseEvent { /** - * A unique identifier for the pointer causing the event. - * - * MDN - */ + * A unique identifier for the pointer causing the event. + * + * MDN + */ def pointerId: Int = js.native /** - * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. - * - * MDN - */ + * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. + * + * MDN + */ def width: Double = js.native /** - * The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. - * - * MDN - */ + * The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. + * + * MDN + */ def height: Double = js.native /** - * The normalized pressure of the pointer input in the range of 0 to 1, - * where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. - * - * MDN - */ + * The normalized pressure of the pointer input in the range of 0 to 1, + * where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. + * + * MDN + */ def pressure: Double = js.native /** - * The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane and the - * plane containing both the transducer (e.g. pen stylus) axis and the Y axis. - * - * MDN - */ + * The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane and the + * plane containing both the transducer (e.g. pen stylus) axis and the Y axis. + * + * MDN + */ def tiltX: Double = js.native /** - * The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane and the - * plane containing both the transducer (e.g. pen stylus) axis and the X axis. - * - * MDN - */ + * The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane and the + * plane containing both the transducer (e.g. pen stylus) axis and the X axis. + * + * MDN + */ def tiltY: Double = js.native /** - * Indicates the device type that caused the event (mouse, pen, touch, etc.) - * - * MDN - */ + * Indicates the device type that caused the event (mouse, pen, touch, etc.) + * + * MDN + */ def pointerType: String = js.native /** - * Indicates if the pointer represents the primary pointer of this pointer type. - * - * In some scenarios there may be multiple pointers (for example a device with both a touchscreen and a mouse) - * or a pointer supports multiple contact points (for example a touchscreen that supports multiple finger touches). - * The application can use the isPrimary property to identify a master pointer - * among the set of active pointers for each pointer type. - * If an application only wants to support a primary pointer, - * it can ignore all pointer events that are not primary. - * - * For mouse there is only one pointer, so it will always be the primary pointer. - * For touch input, a pointer is considered primary if the user touched the screen - * when there were no other active touches. - * For pen and stylus input, a pointer is considered primary if the user's pen - * initially contacted the screenwhen there were no other active pens contacting the screen. - * - * MDN - */ + * Indicates if the pointer represents the primary pointer of this pointer type. + * + * In some scenarios there may be multiple pointers (for example a device with both a touchscreen and a mouse) + * or a pointer supports multiple contact points (for example a touchscreen that supports multiple finger touches). + * The application can use the isPrimary property to identify a master pointer + * among the set of active pointers for each pointer type. + * If an application only wants to support a primary pointer, + * it can ignore all pointer events that are not primary. + * + * For mouse there is only one pointer, so it will always be the primary pointer. + * For touch input, a pointer is considered primary if the user touched the screen + * when there were no other active touches. + * For pen and stylus input, a pointer is considered primary if the user's pen + * initially contacted the screenwhen there were no other active pens contacting the screen. + * + * MDN + */ def isPrimary: Boolean = js.native } @@ -2476,81 +2476,81 @@ class Window def devicePixelRatio: Double = js.native /** - * fired when a pointing device is moved into an element's hit test boundaries. - * - * MDN - */ + * fired when a pointing device is moved into an element's hit test boundaries. + * + * MDN + */ var onpointerover: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointing device is moved into the hit test boundaries of an element - * or one of its descendants, including as a result of a pointerdown event - * from a device that does not support hover (see pointerdown). - * - * MDN - */ + * fired when a pointing device is moved into the hit test boundaries of an element + * or one of its descendants, including as a result of a pointerdown event + * from a device that does not support hover (see pointerdown). + * + * MDN + */ var onpointerenter: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer becomes active. - * - * MDN - */ + * fired when a pointer becomes active. + * + * MDN + */ var onpointerdown: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer changes coordinates. - * - * MDN - */ + * fired when a pointer changes coordinates. + * + * MDN + */ var onpointermove: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointer is no longer active. - * - * MDN - */ + * fired when a pointer is no longer active. + * + * MDN + */ var onpointerup: js.Function1[PointerEvent, _] = js.native /** - * a browser fires this event if it concludes the pointer will no longer be able - * to generate events (for example the related device is deactived). - * - * MDN - */ + * a browser fires this event if it concludes the pointer will no longer be able + * to generate events (for example the related device is deactived). + * + * MDN + */ var onpointercancel: js.Function1[PointerEvent, _] = js.native /** - * fired for several reasons including: pointing device is moved out of - * the hit test boundaries of an element; - * firing the pointerup event for a device that does not support hover (see pointerup); - * after firing the pointercancel event (see pointercancel); - * when a pen stylus leaves the hover range detectable by the digitizer. - * - * MDN - */ + * fired for several reasons including: pointing device is moved out of + * the hit test boundaries of an element; + * firing the pointerup event for a device that does not support hover (see pointerup); + * after firing the pointercancel event (see pointercancel); + * when a pen stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ var onpointerout: js.Function1[PointerEvent, _] = js.native /** - * fired when a pointing device is moved out of the hit test boundaries of an element. - * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. - * - * MDN - */ + * fired when a pointing device is moved out of the hit test boundaries of an element. + * For pen devices, this event is fired when the stylus leaves the hover range detectable by the digitizer. + * + * MDN + */ var onpointerleave: js.Function1[PointerEvent, _] = js.native /** - * fired when an element receives pointer capture. - * - * MDN - */ + * fired when an element receives pointer capture. + * + * MDN + */ var gotpointercapture: js.Function1[PointerEvent, _] = js.native /** - * Fired after pointer capture is released for a pointer. - * - * MDN - */ + * Fired after pointer capture is released for a pointer. + * + * MDN + */ var lostpointercapture: js.Function1[PointerEvent, _] = js.native } From 099013feab654a9b82ea89bfde67c628fb613b8b Mon Sep 17 00:00:00 2001 From: busti Date: Mon, 12 Mar 2018 23:23:27 +0100 Subject: [PATCH 03/10] Reformatting using scalafmt --- src/main/scala/org/scalajs/dom/raw/lib.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index 0008f6ee1..6f4651692 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1470,6 +1470,7 @@ class MouseEvent extends UIEvent with ModifierKeyEvent { @js.native @JSGlobal class PointerEvent extends MouseEvent { + /** * A unique identifier for the pointer causing the event. * From 621e15cf8a84dd2bddc77691830f4a85121158cb Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 14:45:56 +0100 Subject: [PATCH 04/10] Added MDN Credit --- src/main/scala/org/scalajs/dom/raw/lib.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index 6f4651692..54b9d10f4 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1466,6 +1466,8 @@ class MouseEvent extends UIEvent with ModifierKeyEvent { * in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. * In fact, the PointerEvent interface inherits all of the MouseEvent's properties thus facilitating * migrating content from mouse events to pointer events. + * + * MDN */ @js.native @JSGlobal From ae4d798575a4e6c14ac6d4b333500888a3c4f888 Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 14:58:28 +0100 Subject: [PATCH 05/10] Changed pointerId from `Int` to `Double` > https://www.w3.org/TR/pointerevents/#pointerevent-interface says that pointerId is a long in the IDL, so it should be a Double in Scala.js, not an Int (and not a Long either). --- src/main/scala/org/scalajs/dom/raw/lib.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index 54b9d10f4..a4c19fb60 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1478,7 +1478,7 @@ class PointerEvent extends MouseEvent { * * MDN */ - def pointerId: Int = js.native + def pointerId: Double = js.native /** * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. From 950e9c14f0898c80758b5ed5252df44ceda3d106 Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 16:11:40 +0100 Subject: [PATCH 06/10] Added PointerEventInit --- src/main/scala/org/scalajs/dom/raw/lib.scala | 43 +++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index a4c19fb60..76d24fc46 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1471,7 +1471,10 @@ class MouseEvent extends UIEvent with ModifierKeyEvent { */ @js.native @JSGlobal -class PointerEvent extends MouseEvent { +class PointerEvent(typeArg: String, pointerEventInit: PointerEventInit) + extends MouseEvent { + + def this(typeArg: String) = this(typeArg, js.native) /** * A unique identifier for the pointer causing the event. @@ -1546,6 +1549,44 @@ class PointerEvent extends MouseEvent { def isPrimary: Boolean = js.native } +trait PointerEventInit extends js.Object { + + /** + * Sets value of MouseEvent.pointerId. Defaults to 0. + */ + var pointerId: js.undefOr[Double] = js.undefined + + /** + * Sets value of MouseEvent.width. Defaults to 1. + */ + var width: js.UndefOr[Double] = js.undefined + + /** + * Sets value of MouseEvent.height. Defaults to 0. + */ + var height: js.UndefOr[Double] = js.undefined + + /** + * Sets value of MouseEvent.pressure. Defaults to 0. + */ + var pressure: js.UndefOr[Double] = js.undefined + + /** + * Sets value of MouseEvent.tiltX. Defaults to 0. + */ + var tiltX: js.UndefOr[Double] = js.undefined + + /** + * Sets value of MouseEvent.tiltY. Defaults to 0. + */ + var tiltY: js.UndefOr[Double] = js.undefined + + /** + * Sets value of MouseEvent.pointerType. Defaults to 0. + */ + var pointerType: js.UndefOr[String] = js.undefined +} + /** * The TextMetrics interface represents the dimension of a text in the canvas, as * created by the CanvasRenderingContext2D.measureText() method. From d3b6a46ad2c96af705dbaff3faa03fc9a5aa743b Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 16:27:31 +0100 Subject: [PATCH 07/10] Added `tangentialPressure` to PointerEvent --- src/main/scala/org/scalajs/dom/raw/lib.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index 76d24fc46..9a6b400ad 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1505,6 +1505,19 @@ class PointerEvent(typeArg: String, pointerEventInit: PointerEventInit) */ def pressure: Double = js.native + /** + * The tangentialPressure read-only property of the PointerEvent interface + * represents the normalized tangential pressure of the pointer input + * (also known as barrel pressure or cylinder stress) + * in the range -1 to 1, where 0 is the neutral position of the control. + * + * Note that some hardware may only support positive values in the range 0 to 1. + * For hardware that does not support tangential pressure, the value will be 0. + * + * MDN + */ + def tangentialPressure: Double = js.native + /** * The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane and the * plane containing both the transducer (e.g. pen stylus) axis and the Y axis. @@ -1571,6 +1584,11 @@ trait PointerEventInit extends js.Object { */ var pressure: js.UndefOr[Double] = js.undefined + /** + * Sets value of MouseEvent.tangentialPressure. Defaults to 0. + */ + var tangentialPressure: js.UndefOr[Double] = js.undefined + /** * Sets value of MouseEvent.tiltX. Defaults to 0. */ From 1077dee22cb96871757a2b2bcda27024bfc856ec Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 16:51:57 +0100 Subject: [PATCH 08/10] Added `twist` to PointerEvent --- src/main/scala/org/scalajs/dom/raw/lib.scala | 61 +++++++++++++++++--- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index 9a6b400ad..e7cfbc0fe 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1477,21 +1477,28 @@ class PointerEvent(typeArg: String, pointerEventInit: PointerEventInit) def this(typeArg: String) = this(typeArg, js.native) /** - * A unique identifier for the pointer causing the event. + * An identifier assigned to a pointer event that is unique from the identifiers + * of all active pointer events at the time. Authors cannot assume values convey + * any particular meaning other than an identifier for the pointer that is unique + * from all other active pointers. * * MDN */ def pointerId: Double = js.native /** - * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. + * The width read-only property of the PointerEvent interface represents the width of the pointer's + * contact geometry along the x-axis, measured in CSS pixels. Depending on the source of the pointer + * device (such as a finger), for a given pointer, each event may produce a different value. * * MDN */ def width: Double = js.native /** - * The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. + * The height read-only property of the PointerEvent interface represents the height of the pointer's + * contact geometry, along the Y axis (in CSS pixels). Depending on the source of the pointer + * device (for example a finger), for a given pointer, each event may produce a different value. * * MDN */ @@ -1501,6 +1508,9 @@ class PointerEvent(typeArg: String, pointerEventInit: PointerEventInit) * The normalized pressure of the pointer input in the range of 0 to 1, * where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. * + * For hardware that does not support pressure, including but not limited to mouse, + * the value MUST be 0.5 when the pointer is active and 0 otherwise. + * * MDN */ def pressure: Double = js.native @@ -1519,23 +1529,48 @@ class PointerEvent(typeArg: String, pointerEventInit: PointerEventInit) def tangentialPressure: Double = js.native /** - * The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane and the - * plane containing both the transducer (e.g. pen stylus) axis and the Y axis. + * This property is the angle (in degrees) between the Y-Z plane of the pointer and the screen. + * This property is typically only useful for a pen/stylus pointer type. + * The range of values is -90 to 90 degrees and a positive value means a tilt to the right. + * For devices that do not support this property, the value is 0. * * MDN */ def tiltX: Double = js.native /** - * The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane and the - * plane containing both the transducer (e.g. pen stylus) axis and the X axis. + * This property is the angle (in degrees) between the X-Z plane of the pointer and the screen. + * This property is typically only useful for a pen/stylus pointer type. + * The range of values is -90 to 90 degrees and a positive value is a tilt toward the user. + * For devices that do not support this property, the value is 0. * * MDN */ def tiltY: Double = js.native /** - * Indicates the device type that caused the event (mouse, pen, touch, etc.) + * The twist read-only property of the PointerEvent interface represents the clockwise + * rotation of the transducer (e.g. pen stylus) around its major axis in degrees, + * with a value in the range 0 to 359. + * + * For devices that do not report twist, the value MUST be 0. + * + * MDN + */ + def twist: Double = js.native + + /** + * The pointerType read-only property of the PointerEvent interface indicates the device type that caused the pointer event. The supported values are the following strings: + * + * mouse + * The event was generated by a mouse device. + * + * pen + * The event was generated by a pen or stylus device. + * + * touch + * The event was generated by a touch such as a finger. + * If the device type cannot be detected by the browser, the value can be an empty string (""). If the browser supports pointer device types other than those listed above, the value should be vendor prefixed to avoid conflicting names for different types of devices. * * MDN */ @@ -1599,10 +1634,20 @@ trait PointerEventInit extends js.Object { */ var tiltY: js.UndefOr[Double] = js.undefined + /** + * Sets value of MouseEvent.twist. Defaults to 0. + */ + var twist: js.UndefOr[Double] = js.undefined + /** * Sets value of MouseEvent.pointerType. Defaults to 0. */ var pointerType: js.UndefOr[String] = js.undefined + + /** + * Sets value of MouseEvent.isPrimary. Defaults to 0. + */ + var isPrimary: js.UndefOr[Boolean] = js.undefined } /** From 2f846100efbf01310bcbadfc48be06906be14274 Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 18:07:10 +0100 Subject: [PATCH 09/10] Fixed typo --- src/main/scala/org/scalajs/dom/raw/lib.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/org/scalajs/dom/raw/lib.scala b/src/main/scala/org/scalajs/dom/raw/lib.scala index e7cfbc0fe..ec742aefc 100644 --- a/src/main/scala/org/scalajs/dom/raw/lib.scala +++ b/src/main/scala/org/scalajs/dom/raw/lib.scala @@ -1602,7 +1602,7 @@ trait PointerEventInit extends js.Object { /** * Sets value of MouseEvent.pointerId. Defaults to 0. */ - var pointerId: js.undefOr[Double] = js.undefined + var pointerId: js.UndefOr[Double] = js.undefined /** * Sets value of MouseEvent.width. Defaults to 1. From 220c0eec2f2cede7e71801caa508373b2eb66def Mon Sep 17 00:00:00 2001 From: busti Date: Tue, 13 Mar 2018 18:10:59 +0100 Subject: [PATCH 10/10] Added PointerEventInit --- src/main/scala/org/scalajs/dom/package.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/org/scalajs/dom/package.scala b/src/main/scala/org/scalajs/dom/package.scala index 2987a56cb..5b0cd222f 100644 --- a/src/main/scala/org/scalajs/dom/package.scala +++ b/src/main/scala/org/scalajs/dom/package.scala @@ -117,6 +117,7 @@ package object dom { type ModifierKeyEvent = raw.ModifierKeyEvent type MouseEvent = raw.MouseEvent type PointerEvent = raw.PointerEvent + type PointerEventInit = raw.PointerEventInit @deprecated("Obsolete.", "WHATWG DOM") type MutationEvent = raw.MutationEvent @deprecated("Obsolete.", "WHATWG DOM")