1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
use super::*;
/// The Touch class.
/// [`Touch`](https://developer.mozilla.org/en-US/docs/Web/API/Touch)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Touch {
inner: Any,
}
impl FromVal for Touch {
fn from_val(v: &Any) -> Self {
Touch {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for Touch {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Touch {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Touch {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Touch {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Touch> for Any {
fn from(s: Touch) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Touch> for Any {
fn from(s: &Touch) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Touch);
impl Touch {
/// Getter of the `identifier` attribute.
/// [`Touch.identifier`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/identifier)
pub fn identifier(&self) -> i32 {
self.inner.get("identifier").as_::<i32>()
}
}
impl Touch {
/// Getter of the `target` attribute.
/// [`Touch.target`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/target)
pub fn target(&self) -> EventTarget {
self.inner.get("target").as_::<EventTarget>()
}
}
impl Touch {
/// Getter of the `screenX` attribute.
/// [`Touch.screenX`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/screenX)
pub fn screen_x(&self) -> f64 {
self.inner.get("screenX").as_::<f64>()
}
}
impl Touch {
/// Getter of the `screenY` attribute.
/// [`Touch.screenY`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/screenY)
pub fn screen_y(&self) -> f64 {
self.inner.get("screenY").as_::<f64>()
}
}
impl Touch {
/// Getter of the `clientX` attribute.
/// [`Touch.clientX`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/clientX)
pub fn client_x(&self) -> f64 {
self.inner.get("clientX").as_::<f64>()
}
}
impl Touch {
/// Getter of the `clientY` attribute.
/// [`Touch.clientY`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/clientY)
pub fn client_y(&self) -> f64 {
self.inner.get("clientY").as_::<f64>()
}
}
impl Touch {
/// Getter of the `pageX` attribute.
/// [`Touch.pageX`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/pageX)
pub fn page_x(&self) -> f64 {
self.inner.get("pageX").as_::<f64>()
}
}
impl Touch {
/// Getter of the `pageY` attribute.
/// [`Touch.pageY`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/pageY)
pub fn page_y(&self) -> f64 {
self.inner.get("pageY").as_::<f64>()
}
}
impl Touch {
/// Getter of the `radiusX` attribute.
/// [`Touch.radiusX`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/radiusX)
pub fn radius_x(&self) -> f32 {
self.inner.get("radiusX").as_::<f32>()
}
}
impl Touch {
/// Getter of the `radiusY` attribute.
/// [`Touch.radiusY`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/radiusY)
pub fn radius_y(&self) -> f32 {
self.inner.get("radiusY").as_::<f32>()
}
}
impl Touch {
/// Getter of the `rotationAngle` attribute.
/// [`Touch.rotationAngle`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle)
pub fn rotation_angle(&self) -> f32 {
self.inner.get("rotationAngle").as_::<f32>()
}
}
impl Touch {
/// Getter of the `force` attribute.
/// [`Touch.force`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/force)
pub fn force(&self) -> f32 {
self.inner.get("force").as_::<f32>()
}
}
impl Touch {
/// Getter of the `altitudeAngle` attribute.
/// [`Touch.altitudeAngle`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/altitudeAngle)
pub fn altitude_angle(&self) -> f32 {
self.inner.get("altitudeAngle").as_::<f32>()
}
}
impl Touch {
/// Getter of the `azimuthAngle` attribute.
/// [`Touch.azimuthAngle`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/azimuthAngle)
pub fn azimuth_angle(&self) -> f32 {
self.inner.get("azimuthAngle").as_::<f32>()
}
}
impl Touch {
/// Getter of the `touchType` attribute.
/// [`Touch.touchType`](https://developer.mozilla.org/en-US/docs/Web/API/Touch/touchType)
pub fn touch_type(&self) -> TouchType {
self.inner.get("touchType").as_::<TouchType>()
}
}
impl Touch {
/// The `new Touch(..)` constructor, creating a new Touch instance
pub fn new(touch_init_dict: &TouchInit) -> Touch {
Self {
inner: Any::global("Touch")
.new(&[touch_init_dict.into()])
.as_::<Any>(),
}
}
}