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: i32A 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: i32The X coordinate of the touch relative to the viewport.
client_y: i32The Y coordinate of the touch relative to the viewport.
screen_x: i32The X coordinate of the touch relative to the screen.
screen_y: i32The Y coordinate of the touch relative to the screen.
offset_x: i32The X coordinate of the touch relative to the target element.
offset_y: i32The Y coordinate of the touch relative to the target element.
page_x: i32The X coordinate of the touch relative to the page.
page_y: i32The Y coordinate of the touch relative to the page.
Implementations§
Source§impl NativeTouchPoint
Implementation of touch point extraction from DOM touch events.
impl NativeTouchPoint
Implementation of touch point extraction from DOM touch events.
Sourcepub fn extract_all(event: &Event) -> Vec<NativeTouchPoint>
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.
Sourcepub fn extract_changed(event: &Event) -> Vec<NativeTouchPoint>
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
impl NativeTouchPoint
pub fn get_identifier(&self) -> i32
pub fn get_mut_identifier(&mut self) -> &mut i32
pub fn set_identifier(&mut self, val: i32) -> &mut Self
pub fn get_client_x(&self) -> i32
pub fn get_mut_client_x(&mut self) -> &mut i32
pub fn set_client_x(&mut self, val: i32) -> &mut Self
pub fn get_client_y(&self) -> i32
pub fn get_mut_client_y(&mut self) -> &mut i32
pub fn set_client_y(&mut self, val: i32) -> &mut Self
pub fn get_screen_x(&self) -> i32
pub fn get_mut_screen_x(&mut self) -> &mut i32
pub fn set_screen_x(&mut self, val: i32) -> &mut Self
pub fn get_screen_y(&self) -> i32
pub fn get_mut_screen_y(&mut self) -> &mut i32
pub fn set_screen_y(&mut self, val: i32) -> &mut Self
pub fn get_offset_x(&self) -> i32
pub fn get_mut_offset_x(&mut self) -> &mut i32
pub fn set_offset_x(&mut self, val: i32) -> &mut Self
pub fn get_offset_y(&self) -> i32
pub fn get_mut_offset_y(&mut self) -> &mut i32
pub fn set_offset_y(&mut self, val: i32) -> &mut Self
pub fn get_page_x(&self) -> i32
pub fn get_mut_page_x(&mut self) -> &mut i32
pub fn set_page_x(&mut self, val: i32) -> &mut Self
pub fn get_page_y(&self) -> i32
pub fn get_mut_page_y(&mut self) -> &mut i32
pub fn set_page_y(&mut self, val: i32) -> &mut Self
Trait Implementations§
Source§impl Clone for NativeTouchPoint
impl Clone for NativeTouchPoint
Source§fn clone(&self) -> NativeTouchPoint
fn clone(&self) -> NativeTouchPoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NativeTouchPoint
impl Debug for NativeTouchPoint
Source§impl Default for NativeTouchPoint
impl Default for NativeTouchPoint
Source§fn default() -> NativeTouchPoint
fn default() -> NativeTouchPoint
impl Eq for NativeTouchPoint
Source§impl PartialEq for NativeTouchPoint
impl PartialEq for NativeTouchPoint
Source§fn eq(&self, other: &NativeTouchPoint) -> bool
fn eq(&self, other: &NativeTouchPoint) -> bool
self and other values to be equal, and is used by ==.