Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 941217 of Touch

  • Revision slug: Web/API/Touch
  • Revision title: Touch
  • Revision id: 941217
  • Created:
  • Creator: AFBarstow
  • Is current revision? No
  • Comment Fix typo and add reference for Element

Revision Content

{{ APIRef("Touch Events") }}

The Touch interface represents a single contact point on a touch-sensitive device. The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad.

The {{ domxref("Touch.radiusX") }}, {{ domxref("Touch.radiusY") }}, and {{ domxref("Touch.rotationAngle") }} describe the area of contact between the user and the screen, the touch area. This can be helpful when dealing with imprecise pointing devices such as fingers. These values are set to describe an ellipse that as closely as possible matches the entire area of contact (such as the user's fingertip). {{experimental_inline}}

Note: Many of the properties' values are hardware-dependent; for example, if the device doesn't have a way to detect the amount of pressure placed on the surface, the force value will always be 0. This may also be the case for radiusX and radiusY; if the hardware reports only a single point, these values will be 1.

Properties

This interface has no parent, and doesn't inherits or implements any other property.

Basic properties

{{ domxref("Touch.identifier") }} {{readonlyInline}}
Returns a unique identifier for this Touch object. A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. This lets you ensure that you're tracking the same touch all the time.
{{ domxref("Touch.screenX") }} {{readonlyInline}}
Returns the X coordinate of the touch point relative to the left edge of the screen.
{{ domxref("Touch.screenY") }} {{readonlyInline}}
Returns the Y coordinate of the touch point relative to the top edge of the screen.
{{ domxref("Touch.clientX") }} {{readonlyInline}}
Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.
{{ domxref("Touch.clientY") }} {{readonlyInline}}
Returns the Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset.
{{ domxref("Touch.pageX") }} {{readonlyInline}}
Returns the X coordinate of the touch point relative to the left edge of the document. Unlike clientX, this value includes the horizontal scroll offset, if any.
{{ domxref("Touch.pageY") }} {{readonlyInline}}
Returns the Y coordinate of the touch point relative to the top of the document. Unlike clientY, this value includes the vertical scroll offset, if any.
{{ domxref("Touch.target") }} {{readonlyInline}}
Returns the {{ domxref("Element")}} on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element or even been removed from the document.

Touch area

{{SeeCompatTable}}

{{ domxref("Touch.radiusX") }} {{readonlyInline}} {{experimental_inline}}
Returns the X radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenX.
{{ domxref("Touch.radiusY") }} {{readonlyInline}} {{experimental_inline}}
Returns the Y radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenY.
{{ domxref("Touch.rotationAngle") }} {{readonlyInline}} {{experimental_inline}}
Returns the angle (in degrees) that the ellipse described by radiusX and radiusY must be rotated, clockwise, to most accurately cover the area of contact between the user and the surface.
{{ domxref("Touch.force") }}{{readonlyInline}} {{experimental_inline}}
Returns the amount of pressure being applied to the surface by the user, as a float between 0.0 (no pressure) and 1.0 (maximum pressure).

Methods

This interface has no method and no parent, and doesn't inherits or implements any method.

Specifications

Specification Status Comment
{{SpecName('Touch Events 2', '#touch-interface', 'Touch')}} {{Spec2('Touch Events 2')}} Added radiusX, radiusY, rotationAngle, force properties
{{SpecName('Touch Events', '#touch-interface', 'Touch')}} {{Spec2('Touch Events')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome("22.0")}} {{CompatGeckoDesktop("18.0")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
radiusX, radiusY, rotationAngle, force          
Feature Android Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatGeckoMobile("6.0")}} {{CompatVersionUnknown}} 11 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
radiusX, radiusY, rotationAngle, force                

See also

  • Touch events
  • {{ domxref("TouchList") }}
  • {{ domxref("TouchEvent") }}
  • {{ domxref("Document.createTouch()") }}

Revision Source

<p>{{ APIRef("Touch Events") }}</p>

<p>The <strong><code>Touch</code></strong> interface represents a single contact point on a touch-sensitive device. The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad.</p>

<p>The {{ domxref("Touch.radiusX") }}, {{ domxref("Touch.radiusY") }}, and {{ domxref("Touch.rotationAngle") }}&nbsp;describe the area of contact between the user and the screen, the <em>touch area</em>. This can be helpful when dealing with imprecise pointing devices such as fingers. These values are set to describe an ellipse that as closely as possible matches the entire area of contact (such as the user's fingertip). {{experimental_inline}}</p>

<div class="note">
<p><strong>Note:</strong> Many of the properties' values are hardware-dependent; for example, if the device doesn't have a way to detect the amount of pressure placed on the surface, the <code>force</code> value will always be 0. This may also be the case for <code>radiusX</code>&nbsp;and <code>radiusY</code>; if the hardware reports only a single point, these values will be 1.</p>
</div>

<h2 id="Properties">Properties</h2>

<p><em>This interface has no parent, and doesn't inherits or implements any other property.</em></p>

<h3 id="Basic_properties">Basic properties</h3>

<dl>
 <dt>{{ domxref("Touch.identifier") }} {{readonlyInline}}</dt>
 <dd>Returns a unique identifier for this <code>Touch</code> object. A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. This lets you ensure that you're tracking the same touch all the time.</dd>
 <dt><strong>{{ domxref("Touch.screenX") }} </strong>{{readonlyInline}}</dt>
 <dd>Returns the X coordinate of the touch point relative to the left edge of the screen.</dd>
 <dt><strong>{{ domxref("Touch.screenY") }} </strong>{{readonlyInline}}</dt>
 <dd>Returns the Y coordinate of the touch point relative to the top edge of the screen.</dd>
 <dt><strong>{{ domxref("Touch.clientX") }} </strong>{{readonlyInline}}</dt>
 <dd>Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.</dd>
 <dt><strong>{{ domxref("Touch.clientY") }} </strong>{{readonlyInline}}</dt>
 <dd>Returns the Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset.</dd>
 <dt>{{ domxref("Touch.pageX") }} {{readonlyInline}}</dt>
 <dd>Returns the X coordinate of the touch point relative to the left edge of the document. Unlike <code>clientX</code>, this value includes the horizontal scroll offset, if any.</dd>
 <dt>{{ domxref("Touch.pageY") }} {{readonlyInline}}</dt>
 <dd>Returns the Y coordinate of the touch point relative to the top of the document. Unlike <code>clientY,</code> this value includes the vertical scroll offset, if any.</dd>
 <dt>{{ domxref("Touch.target") }} {{readonlyInline}}</dt>
 <dd>Returns the {{ domxref("Element")}} on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element or even been removed from the document.</dd>
</dl>

<h3 id="Touch_area">Touch area</h3>

<p>{{SeeCompatTable}}</p>

<dl>
 <dt>{{ domxref("Touch.radiusX") }} {{readonlyInline}} {{experimental_inline}}</dt>
 <dd>Returns the X radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as <code>screenX</code>.</dd>
 <dt>{{ domxref("Touch.radiusY") }} {{readonlyInline}} {{experimental_inline}}</dt>
 <dd>Returns the Y radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as <code>screenY</code>.</dd>
 <dt>{{ domxref("Touch.rotationAngle") }} {{readonlyInline}} {{experimental_inline}}</dt>
 <dd>Returns the angle (in degrees)&nbsp;that the ellipse described by radiusX and radiusY must be rotated, clockwise, to most accurately cover the area of contact between the user and the surface.</dd>
 <dt>{{ domxref("Touch.force") }}{{readonlyInline}} {{experimental_inline}}</dt>
 <dd>Returns the amount of pressure being applied to the surface by the user, as a <code>float</code> between <code>0.0</code> (no pressure) and <code>1.0</code> (maximum pressure).</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em>This interface has no method and no parent, and doesn't inherits or implements any method.</em></p>

<dl>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Touch Events 2', '#touch-interface', 'Touch')}}</td>
   <td>{{Spec2('Touch Events 2')}}</td>
   <td>Added <code>radiusX</code>, <code>radiusY</code>, <code>rotationAngle</code>, <code>force</code> properties</td>
  </tr>
  <tr>
   <td>{{SpecName('Touch Events', '#touch-interface', 'Touch')}}</td>
   <td>{{Spec2('Touch Events')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome("22.0")}}</td>
   <td>{{CompatGeckoDesktop("18.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>radiusX</code>, <code>radiusY</code>, <code>rotationAngle</code>, <code>force</code></td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("6.0")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>11</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>radiusX</code>, <code>radiusY</code>, <code>rotationAngle</code>, <code>force</code></td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en/DOM/Touch_events" title="en/DOM/Touch events">Touch events</a></li>
 <li>{{ domxref("TouchList") }}</li>
 <li>{{ domxref("TouchEvent") }}</li>
 <li>{{ domxref("Document.createTouch()") }}</li>
</ul>

<dl>
</dl>
Revert to this revision