diff --git a/index.html b/index.html index e82ef61..4b084a2 100644 --- a/index.html +++ b/index.html @@ -192,6 +192,34 @@

Examples

pointerEventInitDict.coalescedEvents = [p1, p2]; const event2 = new PointerEvent("pointermove", pointerEventInitDict); eventTarget.dispatchEvent(event2); + +
+    <div style="position:absolute; top:0px; left:0px; width:100px;height:100px;"></div>
+    <script>
+    window.addEventListener("pointerdown", assignPenColor);
+    window.addEventListener("pointermove", assignPenColor);
+    const colorMap = new Map();
+
+    function assignPenColor(event) {
+        const uniqueId = event.persistentDeviceId;
+        // Check if a unique Id exists.
+        if (uniqueId == 0) {
+            return;
+        }
+        // Check if a color has been assigned to the device.
+        if (map.has(uniqueId)) {
+            return;
+        }
+        // Assign a color to the device.
+        let newColor = getNewColor();
+        map.set(uniqueId, newColor);
+        return newColor;
+    }
+
+    function getNewColor() {
+        /* return some color value */
+    }
+    </script>
 
@@ -214,6 +242,7 @@

PointerEvent interface

double azimuthAngle; DOMString pointerType = ""; boolean isPrimary = false; + long persistentDeviceId = 0; sequence<PointerEvent> coalescedEvents = []; sequence<PointerEvent> predictedEvents = []; }; @@ -233,6 +262,7 @@

PointerEvent interface

readonly attribute double azimuthAngle; readonly attribute DOMString pointerType; readonly attribute boolean isPrimary; + readonly attribute long persistentDeviceId; [SecureContext] sequence<PointerEvent> getCoalescedEvents(); sequence<PointerEvent> getPredictedEvents(); }; @@ -325,6 +355,11 @@

PointerEvent interface

Indicates if the pointer represents the primary pointer of this pointer type.

+
persistentDeviceId
+
+

A unique identifier for the pointing device. If the hardware supports multiple pointers, pointer events generated from pointing devices MUST only get a persistentDeviceId if those pointers are uniquely identifiable over the session. If the pointer is uniquely identifiable, the assigned persistentDeviceId to that pointing device will remain constant for the remainder of the session. The persistentDeviceId value of 0 MUST be reserved and used to indicate events whose generating device could not be identified. Like pointerId, to minimize the chance of fingerprinting and tracking across different pages or domains, the persistentDeviceId MUST only be associated explicitly with that particular pointing device for the lifetime of the page / session, and a new randomized persistentDeviceId MUST be chosen the next time that particular pointing device is used again in a new session.

+
Due to digitizer and pointing device hardware constraints, a persistentDeviceId is not guaranteed to be available for all pointer events from a pointing device. For example, the device may not report its hardware id to the digitizer in time for pointerdown to have a persistentDeviceId. In such a case, the persistentDeviceId may initially be 0 and change to a valid value.
+
getCoalescedEvents()

A method that returns the list of coalesced events.

@@ -578,7 +613,7 @@

Converting between tiltX / tiltY and altitud

Pointer Events include two complementary sets of attributes to express the orientation of a transducer relative to the X-Y plane: tiltX / tiltY (introduced in the original Pointer Events specification), and azimuthAngle / altitudeAngle (adopted from the Touch Events - Level 2 specification).

Depending on the specific hardware and platform, user agents will likely only receive one set of values for the transducer orientation relative to the screen plane — either tiltX / tiltY or altitudeAngle / azimuthAngle. User agents MUST use the following algorithm for converting these values.

When the user agent calculates tiltX / tiltY from azimuthAngle / altitudeAngle it SHOULD round the final integer values using Math.round [[ECMASCRIPT]] rules.

-
/* Converting between tiltX/tiltY and altitudeAngle/azimuthAngle */
+
/* Converting between tiltX/tiltY and altitudeAngle/azimuthAngle */
 
 function spherical2tilt(altitudeAngle, azimuthAngle) {
   const radToDeg = 180/Math.PI;
@@ -683,7 +718,6 @@ 

Converting between tiltX / tiltY and altitud

-

Pointer Event types

Below are the event types defined in this specification.

@@ -1028,17 +1062,17 @@

Details of touch-action valu
Disabling some default direct manipulation behaviors for panning and zooming may allow user agents to respond to other behaviors more quickly. For example, with auto user agents typically add 300ms of delay before click to allow for double-tap gestures to be handled. In these cases, explicitly setting touch-action: none or touch-action: manipulation will remove this delay. Note that the methods for determining a tap or double-tap gesture are out of scope for this specification.

-
+
 <div style="touch-action: none;">
     This element receives pointer events for all direct manipulation interactions that otherwise lead to panning or zooming.
 </div>
 
-
+
 <div style="touch-action: pan-x;">
     This element receives pointer events when not panning in the horizontal direction.
 </div>
 
-
+
 <div style="overflow: auto;">
     <div style="touch-action: none;">
         This element receives pointer events for all direct manipulation interactions that otherwise lead to panning or zooming.
@@ -1048,7 +1082,7 @@ 

Details of touch-action valu </div> </div>

-
+
 <div style="overflow: auto;">
     <div style="touch-action: pan-y;">
         <div style="touch-action: pan-x;">
@@ -1061,7 +1095,7 @@ 

Details of touch-action valu </div> </div>

-
+
 <div style="overflow: auto;">
     <div style="touch-action: pan-y pan-left;">
         <div style="touch-action: pan-x;">
@@ -1191,7 +1225,7 @@ 

Coalesced events

  • Empty coalesced events list and predicted events list of their own.
  • -
    +
     <style>
         /* Disable intrinsic user agent direct manipulation behaviors (such as panning or zooming)
         so that all events on the canvas element are given to the application instead. */
    @@ -1307,7 +1341,7 @@ 

    Predicted events

    pointer events are dispatched earlier than the timestamp of one or more of the predicted events.

    -
    +
     
     let predicted_points = [];
     window.addEventListener("pointermove", function(event) {