Skip to main content

NativeTouchPoint

Struct NativeTouchPoint 

Source
pub struct NativeTouchPoint {
    pub identifier: i32,
    pub client_x: i32,
    pub client_y: i32,
    pub screen_x: i32,
    pub screen_y: i32,
    pub offset_x: i32,
    pub offset_y: i32,
    pub page_x: i32,
    pub page_y: i32,
}
Expand description

Represents a single touch point from a multi-touch event.

Each NativeTouchPoint corresponds to one finger or stylus currently touching the screen. The identifier field distinguishes between simultaneous touch points, enabling multi-finger gesture tracking.

Fields§

§identifier: i32

A unique identifier for this touch point.

The browser assigns a distinct identifier to each active touch. It remains constant for the duration of the touch (from touchstart to touchend), allowing the same finger to be tracked across touchmove events.

§client_x: i32

The X coordinate of the touch relative to the viewport.

§client_y: i32

The Y coordinate of the touch relative to the viewport.

§screen_x: i32

The X coordinate of the touch relative to the screen.

§screen_y: i32

The Y coordinate of the touch relative to the screen.

§offset_x: i32

The X coordinate of the touch relative to the target element.

§offset_y: i32

The Y coordinate of the touch relative to the target element.

§page_x: i32

The X coordinate of the touch relative to the page.

§page_y: i32

The Y coordinate of the touch relative to the page.

Implementations§

Source§

impl NativeTouchPoint

Implementation of touch point extraction from DOM touch events.

Source

pub fn extract_all(event: &Event) -> Vec<NativeTouchPoint>

Extracts all active touch points from a TouchEvent.

Iterates over the touches list of the given TouchEvent and builds a Vec<NativeTouchPoint> with each touch point’s identifier, viewport coordinates, screen coordinates, page coordinates, and offset coordinates relative to the target element.

The offset coordinates (offset_x, offset_y) are computed by subtracting the target element’s bounding rect from the touch’s client coordinates, since the browser Touch object does not provide offsetX/offsetY directly.

§Arguments
  • &Event: The native DOM touch event.
§Returns
  • Vec<NativeTouchPoint>: All currently active touch points.
Source

pub fn extract_changed(event: &Event) -> Vec<NativeTouchPoint>

Extracts the changed touch points from a TouchEvent.

The changedTouches list contains touch points that have changed since the last touch event:

  • For touchstart - newly added touch points.
  • For touchmove - touch points that have moved.
  • For touchend / touchcancel - removed touch points.

This is useful for determining which specific fingers were lifted in a touchend event, since the touches list no longer contains them.

§Arguments
  • &Event: The native DOM touch event.
§Returns
  • Vec<NativeTouchPoint>: The touch points that changed in this event.
Source§

impl NativeTouchPoint

Source

pub fn get_identifier(&self) -> i32

Source

pub fn get_mut_identifier(&mut self) -> &mut i32

Source

pub fn set_identifier(&mut self, val: i32) -> &mut Self

Source

pub fn get_client_x(&self) -> i32

Source

pub fn get_mut_client_x(&mut self) -> &mut i32

Source

pub fn set_client_x(&mut self, val: i32) -> &mut Self

Source

pub fn get_client_y(&self) -> i32

Source

pub fn get_mut_client_y(&mut self) -> &mut i32

Source

pub fn set_client_y(&mut self, val: i32) -> &mut Self

Source

pub fn get_screen_x(&self) -> i32

Source

pub fn get_mut_screen_x(&mut self) -> &mut i32

Source

pub fn set_screen_x(&mut self, val: i32) -> &mut Self

Source

pub fn get_screen_y(&self) -> i32

Source

pub fn get_mut_screen_y(&mut self) -> &mut i32

Source

pub fn set_screen_y(&mut self, val: i32) -> &mut Self

Source

pub fn get_offset_x(&self) -> i32

Source

pub fn get_mut_offset_x(&mut self) -> &mut i32

Source

pub fn set_offset_x(&mut self, val: i32) -> &mut Self

Source

pub fn get_offset_y(&self) -> i32

Source

pub fn get_mut_offset_y(&mut self) -> &mut i32

Source

pub fn set_offset_y(&mut self, val: i32) -> &mut Self

Source

pub fn get_page_x(&self) -> i32

Source

pub fn get_mut_page_x(&mut self) -> &mut i32

Source

pub fn set_page_x(&mut self, val: i32) -> &mut Self

Source

pub fn get_page_y(&self) -> i32

Source

pub fn get_mut_page_y(&mut self) -> &mut i32

Source

pub fn set_page_y(&mut self, val: i32) -> &mut Self

Trait Implementations§

Source§

impl Clone for NativeTouchPoint

Source§

fn clone(&self) -> NativeTouchPoint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NativeTouchPoint

Source§

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

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

impl Default for NativeTouchPoint

Source§

fn default() -> NativeTouchPoint

Returns the “default value” for a type. Read more
Source§

impl Eq for NativeTouchPoint

Source§

impl PartialEq for NativeTouchPoint

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for NativeTouchPoint

Auto Trait Implementations§

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more