Struct Touch

Source
pub struct Touch(/* private fields */);
Expand description

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.

(JavaScript docs)

Implementations§

Source§

impl Touch

Source

pub fn identifier(&self) -> i32

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.

(JavaScript docs)

Source

pub fn screen_x(&self) -> f64

Returns the X coordinate of the touch point relative to the left edge of the screen.

(JavaScript docs)

Source

pub fn screen_y(&self) -> f64

Returns the Y coordinate of the touch point relative to the left edge of the screen.

(JavaScript docs)

Source

pub fn client_x(&self) -> f64

Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.

(JavaScript docs)

Source

pub fn client_y(&self) -> f64

Returns the Y coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.

(JavaScript docs)

Source

pub fn page_x(&self) -> f64

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.

(JavaScript docs)

Source

pub fn page_y(&self) -> f64

Returns the Y coordinate of the touch point relative to the left edge of the document. Unlike clientX, this value includes the horizontal scroll offset, if any.

(JavaScript docs)

Source

pub fn target(&self) -> EventTarget

Returns the 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.

(JavaScript docs)

Source

pub fn radius_x(&self) -> f64

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.

(JavaScript docs)

Source

pub fn radius_y(&self) -> f64

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.

(JavaScript docs)

Source

pub fn rotation_angle(&self) -> f64

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.

(JavaScript docs)

Source

pub fn force(&self) -> f64

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).

(JavaScript docs)

Source

pub fn altitude_angle(&self) -> f64

The altitude (in radians) of a stylus, in the range 0 (parallel to the surface) to π/2 (perpendicular to the surface). The value 0 should be used for devices which do not support this property.

(JavaScript docs)

Source

pub fn azimuth_angle(&self) -> f64

The azimuth angle (in radians) of a stylus, in the range 0 to 2π. 0 represents a stylus whose cap is pointing in the direction of increasing screenX values. π/2 represents a stylus whose cap is pointing in the direction of increasing screenY values. The value 0 should be used for devices which do not support this property.

(JavaScript docs)

Source

pub fn touch_type(&self) -> TouchType

The type of device used to trigger the touch.

Trait Implementations§

Source§

impl AsRef<Reference> for Touch

Source§

fn as_ref(&self) -> &Reference

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Touch

Source§

fn clone(&self) -> Touch

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Touch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Touch> for Reference

Source§

fn from(value: Touch) -> Self

Converts to this type from the input type.
Source§

impl InstanceOf for Touch

Source§

fn instance_of(reference: &Reference) -> bool

Checks whenever a given Reference if of type Self.
Source§

impl PartialEq for Touch

Source§

fn eq(&self, other: &Touch) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ReferenceType for Touch

Source§

unsafe fn from_reference_unchecked(reference: Reference) -> Self

Converts a given reference into a concrete reference-like wrapper. Doesn’t do any type checking; highly unsafe to use!
Source§

impl<'_r> TryFrom<&'_r Reference> for Touch

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(reference: &Reference) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'_r> TryFrom<&'_r Value> for Touch

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Reference> for Touch

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(reference: Reference) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Touch> for Reference

Source§

type Error = Void

The type returned in the event of a conversion error.
Source§

fn try_from(value: Touch) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Touch

Source§

type Error = ConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Touch

Source§

impl JsSerialize for Touch

Source§

impl StructuralPartialEq for Touch

Auto Trait Implementations§

§

impl Freeze for Touch

§

impl RefUnwindSafe for Touch

§

impl Send for Touch

§

impl Sync for Touch

§

impl Unpin for Touch

§

impl UnwindSafe for Touch

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.