Compare commits
5 Commits
54549992a3
...
6f45e6b774
Author | SHA1 | Date |
---|---|---|
Michael Pfaff | 6f45e6b774 | |
Michael Pfaff | c993632102 | |
Pauan | f98db04ef7 | |
Pauan | fbeeac563b | |
Peter Frank | 8bc2439caa |
|
@ -1,3 +1,7 @@
|
|||
## UNRELEASED
|
||||
* Adding in `submit` event.
|
||||
* Adding in `touchstart`, `touchmove`, `touchend`, and `touchcancel` events.
|
||||
|
||||
## 0.5.24 - (2022-04-12)
|
||||
* Adding in `AnimationStart`, `AnimationIteration`, `AnimationCancel`, `AnimationEnd`, `FocusIn`, `FocusOut`, and `Wheel` events.
|
||||
* Adding in numerous `Pointer*` events.
|
||||
|
|
|
@ -49,7 +49,7 @@ struct User {
|
|||
impl User {
|
||||
async fn fetch(user: &str) -> Result<Self, JsValue> {
|
||||
let user = fetch_github(&format!("https://api.github.com/users/{}", user)).await?;
|
||||
Ok(serde_json::from_str::<Self>(&user).unwrap_throw())
|
||||
Ok(serde_json::from_str::<Self>(&user).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ pub async fn fetch_github(url: &str) -> Result<String, JsValue> {
|
|||
headers.set("Accept", "application/vnd.github.v3+json")?;
|
||||
|
||||
let future = window()
|
||||
.unwrap_throw()
|
||||
.unwrap()
|
||||
.fetch_with_str_and_init(
|
||||
url,
|
||||
RequestInit::new()
|
||||
|
@ -131,7 +131,7 @@ pub async fn fetch_github(url: &str) -> Result<String, JsValue> {
|
|||
let value = JsFuture::from(response.text()?)
|
||||
.await?
|
||||
.as_string()
|
||||
.unwrap_throw();
|
||||
.unwrap();
|
||||
|
||||
Ok(value)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub enum Route {
|
|||
impl Route {
|
||||
// This could use more advanced URL parsing, but it isn't needed
|
||||
pub fn from_url(url: &str) -> Self {
|
||||
let url = Url::new(&url).unwrap_throw();
|
||||
let url = Url::new(&url).unwrap();
|
||||
match url.hash().as_str() {
|
||||
"#/active" => Route::Active,
|
||||
"#/completed" => Route::Completed,
|
||||
|
@ -72,7 +72,7 @@ impl App {
|
|||
pub fn deserialize() -> Arc<Self> {
|
||||
local_storage()
|
||||
.get_item("todos-rust-dominator")
|
||||
.unwrap_throw()
|
||||
.unwrap()
|
||||
.and_then(|state_json| {
|
||||
serde_json::from_str(state_json.as_str()).ok()
|
||||
})
|
||||
|
@ -80,11 +80,11 @@ impl App {
|
|||
}
|
||||
|
||||
pub fn serialize(&self) {
|
||||
let state_json = serde_json::to_string(self).unwrap_throw();
|
||||
let state_json = serde_json::to_string(self).unwrap();
|
||||
|
||||
local_storage()
|
||||
.set_item("todos-rust-dominator", state_json.as_str())
|
||||
.unwrap_throw();
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn route(&self) -> impl Signal<Item = Route> {
|
||||
|
|
|
@ -126,7 +126,7 @@ impl Todo {
|
|||
.event(clone!(todo => move |event: events::KeyDown| {
|
||||
match event.key().as_str() {
|
||||
"Enter" => {
|
||||
element.blur().unwrap_throw();
|
||||
element.blur().unwrap();
|
||||
},
|
||||
"Escape" => {
|
||||
todo.cancel_editing();
|
||||
|
|
|
@ -3,7 +3,7 @@ use web_sys::{window, Storage};
|
|||
|
||||
|
||||
pub fn local_storage() -> Storage {
|
||||
window().unwrap_throw().local_storage().unwrap_throw().unwrap_throw()
|
||||
window().unwrap().local_storage().unwrap().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -11,7 +11,7 @@ use futures_signals::signal::{Signal, SignalExt, WaitFor, MutableSignal, Mutable
|
|||
use futures_signals::signal_vec::{SignalVec, VecDiff};
|
||||
use discard::DiscardOnDrop;
|
||||
use pin_project::pin_project;
|
||||
use wasm_bindgen::{JsCast, UnwrapThrowExt};
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use web_sys::window;
|
||||
|
||||
|
@ -35,9 +35,9 @@ impl Raf {
|
|||
|
||||
fn schedule(callback: &Closure<dyn FnMut(f64)>) -> i32 {
|
||||
window()
|
||||
.unwrap_throw()
|
||||
.unwrap()
|
||||
.request_animation_frame(callback.as_ref().unchecked_ref())
|
||||
.unwrap_throw()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
let closure = {
|
||||
|
@ -46,7 +46,7 @@ impl Raf {
|
|||
Closure::wrap(Box::new(move |time| {
|
||||
{
|
||||
let mut state = state.borrow_mut();
|
||||
let state = state.as_mut().unwrap_throw();
|
||||
let state = state.as_mut().unwrap();
|
||||
state.id = schedule(&state.closure);
|
||||
}
|
||||
|
||||
|
@ -66,12 +66,12 @@ impl Raf {
|
|||
impl Drop for Raf {
|
||||
fn drop(&mut self) {
|
||||
// The take is necessary in order to prevent an Rc leak
|
||||
let state = self.state.borrow_mut().take().unwrap_throw();
|
||||
let state = self.state.borrow_mut().take().unwrap();
|
||||
|
||||
window()
|
||||
.unwrap_throw()
|
||||
.unwrap()
|
||||
.cancel_animation_frame(state.id)
|
||||
.unwrap_throw();
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl Signal for Timestamps {
|
|||
|
||||
// TODO implement Poll::Ready(None)
|
||||
fn poll_change(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
let mut lock = self.state.lock().unwrap_throw();
|
||||
let mut lock = self.state.lock().unwrap();
|
||||
|
||||
if lock.changed {
|
||||
lock.changed = false;
|
||||
|
@ -164,7 +164,7 @@ pub fn timestamps() -> Timestamps {
|
|||
|
||||
lock.states.retain(|state| {
|
||||
if let Some(state) = state.upgrade() {
|
||||
let mut lock = state.lock().unwrap_throw();
|
||||
let mut lock = state.lock().unwrap();
|
||||
|
||||
lock.changed = true;
|
||||
lock.value = Some(time);
|
||||
|
@ -367,7 +367,7 @@ impl<A, F, S> SignalVec for AnimatedMap<S, F>
|
|||
},
|
||||
|
||||
VecDiff::UpdateAt { index, value } => {
|
||||
let index = Self::find_index(&animations, index).unwrap_throw();
|
||||
let index = Self::find_index(&animations, index).unwrap();
|
||||
let state = {
|
||||
let state = &animations[index];
|
||||
AnimatedMapBroadcaster(state.animation.raw_clone())
|
||||
|
@ -379,7 +379,7 @@ impl<A, F, S> SignalVec for AnimatedMap<S, F>
|
|||
// TODO test this
|
||||
// TODO should this be treated as a removal + insertion ?
|
||||
VecDiff::Move { old_index, new_index } => {
|
||||
let old_index = Self::find_index(&animations, old_index).unwrap_throw();
|
||||
let old_index = Self::find_index(&animations, old_index).unwrap();
|
||||
|
||||
let state = animations.remove(old_index);
|
||||
|
||||
|
@ -391,7 +391,7 @@ impl<A, F, S> SignalVec for AnimatedMap<S, F>
|
|||
},
|
||||
|
||||
VecDiff::RemoveAt { index } => {
|
||||
let index = Self::find_index(&animations, index).unwrap_throw();
|
||||
let index = Self::find_index(&animations, index).unwrap();
|
||||
|
||||
if Self::should_remove(&mut animations, cx, index) {
|
||||
Self::remove_index(&mut animations, index)
|
||||
|
@ -402,7 +402,7 @@ impl<A, F, S> SignalVec for AnimatedMap<S, F>
|
|||
},
|
||||
|
||||
VecDiff::Pop {} => {
|
||||
let index = Self::find_last_index(&animations).unwrap_throw();
|
||||
let index = Self::find_last_index(&animations).unwrap();
|
||||
|
||||
if Self::should_remove(&mut animations, cx, index) {
|
||||
Self::remove_index(&mut animations, index)
|
||||
|
@ -533,12 +533,12 @@ impl MutableTimestamps<F> where F: FnMut(f64) {
|
|||
}
|
||||
|
||||
pub fn stop(&self) {
|
||||
let mut lock = self.animating.lock().unwrap_throw();
|
||||
let mut lock = self.animating.lock().unwrap();
|
||||
*lock = None;
|
||||
}
|
||||
|
||||
pub fn start(&self) {
|
||||
let mut lock = self.animating.lock().unwrap_throw();
|
||||
let mut lock = self.animating.lock().unwrap();
|
||||
|
||||
if let None = animating {
|
||||
let callback = self.callback.clone();
|
||||
|
@ -639,7 +639,7 @@ pub struct MutableAnimation {
|
|||
|
||||
impl fmt::Debug for MutableAnimation {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let state = self.inner.state.lock().unwrap_throw();
|
||||
let state = self.inner.state.lock().unwrap();
|
||||
|
||||
fmt.debug_struct("MutableAnimation")
|
||||
.field("playing", &state.playing)
|
||||
|
@ -703,7 +703,7 @@ impl MutableAnimation {
|
|||
// TODO test the performance of set_neq
|
||||
if diff >= 1.0 {
|
||||
{
|
||||
let mut lock = state.inner.state.lock().unwrap_throw();
|
||||
let mut lock = state.inner.state.lock().unwrap();
|
||||
Self::stop_animating(&mut lock);
|
||||
}
|
||||
state.inner.value.set_neq(Percentage::new_unchecked(end));
|
||||
|
@ -728,7 +728,7 @@ impl MutableAnimation {
|
|||
pub fn set_duration(&self, duration: f64) {
|
||||
debug_assert!(duration >= 0.0);
|
||||
|
||||
let mut lock = self.inner.state.lock().unwrap_throw();
|
||||
let mut lock = self.inner.state.lock().unwrap();
|
||||
|
||||
if lock.duration != duration {
|
||||
lock.duration = duration;
|
||||
|
@ -738,7 +738,7 @@ impl MutableAnimation {
|
|||
|
||||
#[inline]
|
||||
pub fn pause(&self) {
|
||||
let mut lock = self.inner.state.lock().unwrap_throw();
|
||||
let mut lock = self.inner.state.lock().unwrap();
|
||||
|
||||
if lock.playing {
|
||||
lock.playing = false;
|
||||
|
@ -748,7 +748,7 @@ impl MutableAnimation {
|
|||
|
||||
#[inline]
|
||||
pub fn play(&self) {
|
||||
let mut lock = self.inner.state.lock().unwrap_throw();
|
||||
let mut lock = self.inner.state.lock().unwrap();
|
||||
|
||||
if !lock.playing {
|
||||
lock.playing = true;
|
||||
|
@ -765,13 +765,13 @@ impl MutableAnimation {
|
|||
}
|
||||
|
||||
pub fn jump_to(&self, end: Percentage) {
|
||||
let mut lock = self.inner.state.lock().unwrap_throw();
|
||||
let mut lock = self.inner.state.lock().unwrap();
|
||||
|
||||
Self::_jump_to(&mut lock, &self.inner.value, end);
|
||||
}
|
||||
|
||||
pub fn animate_to(&self, end: Percentage) {
|
||||
let mut lock = self.inner.state.lock().unwrap_throw();
|
||||
let mut lock = self.inner.state.lock().unwrap();
|
||||
|
||||
if lock.end != end {
|
||||
if lock.duration <= 0.0 {
|
||||
|
|
|
@ -40,9 +40,9 @@ extern "C" {
|
|||
|
||||
|
||||
thread_local! {
|
||||
static WINDOW: Window = web_sys::window().unwrap_throw();
|
||||
static DOCUMENT: Document = WINDOW.with(|w| w.document().unwrap_throw());
|
||||
static HISTORY: History = WINDOW.with(|w| w.history().unwrap_throw());
|
||||
static WINDOW: Window = web_sys::window().unwrap();
|
||||
static DOCUMENT: Document = WINDOW.with(|w| w.document().unwrap());
|
||||
static HISTORY: History = WINDOW.with(|w| w.history().unwrap());
|
||||
}
|
||||
|
||||
pub(crate) fn window_event_target() -> EventTarget {
|
||||
|
@ -51,7 +51,7 @@ pub(crate) fn window_event_target() -> EventTarget {
|
|||
}
|
||||
|
||||
pub(crate) fn body() -> HtmlElement {
|
||||
DOCUMENT.with(|d| d.body().unwrap_throw())
|
||||
DOCUMENT.with(|d| d.body().unwrap())
|
||||
}
|
||||
|
||||
pub(crate) fn ready_state() -> String {
|
||||
|
@ -59,12 +59,12 @@ pub(crate) fn ready_state() -> String {
|
|||
}
|
||||
|
||||
pub(crate) fn current_url() -> String {
|
||||
WINDOW.with(|w| w.location().href().unwrap_throw())
|
||||
WINDOW.with(|w| w.location().href().unwrap())
|
||||
}
|
||||
|
||||
pub(crate) fn go_to_url(url: &str) {
|
||||
HISTORY.with(|h| {
|
||||
h.push_state_with_url(&JsValue::NULL, "", Some(url)).unwrap_throw();
|
||||
h.push_state_with_url(&JsValue::NULL, "", Some(url)).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -72,34 +72,34 @@ pub(crate) fn create_stylesheet() -> CssStyleSheet {
|
|||
DOCUMENT.with(|document| {
|
||||
// TODO use createElementNS ?
|
||||
// TODO use dyn_into ?
|
||||
let e: HtmlStyleElement = document.create_element("style").unwrap_throw().unchecked_into();
|
||||
let e: HtmlStyleElement = document.create_element("style").unwrap().unchecked_into();
|
||||
e.set_type("text/css");
|
||||
append_child(&document.head().unwrap_throw(), &e);
|
||||
append_child(&document.head().unwrap(), &e);
|
||||
// TODO use dyn_into ?
|
||||
e.sheet().unwrap_throw().unchecked_into()
|
||||
e.sheet().unwrap().unchecked_into()
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn make_style_rule(sheet: &CssStyleSheet, selector: &str) -> Result<CssStyleRule, JsValue> {
|
||||
let rules = sheet.css_rules().unwrap_throw();
|
||||
let rules = sheet.css_rules().unwrap();
|
||||
let length = rules.length();
|
||||
// TODO don't return u32 ?
|
||||
sheet.insert_rule_with_index(&format!("{}{{}}", selector), length)?;
|
||||
// TODO use dyn_into ?
|
||||
Ok(rules.get(length).unwrap_throw().unchecked_into())
|
||||
Ok(rules.get(length).unwrap().unchecked_into())
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn get_element_by_id(id: &str) -> Element {
|
||||
DOCUMENT.with(|d| d.get_element_by_id(id).unwrap_throw())
|
||||
DOCUMENT.with(|d| d.get_element_by_id(id).unwrap())
|
||||
}
|
||||
|
||||
pub(crate) fn create_element(name: &str) -> Element {
|
||||
DOCUMENT.with(|d| d.create_element(name).unwrap_throw())
|
||||
DOCUMENT.with(|d| d.create_element(name).unwrap())
|
||||
}
|
||||
|
||||
pub(crate) fn create_element_ns(namespace: &str, name: &str) -> Element {
|
||||
DOCUMENT.with(|d| d.create_element_ns(Some(namespace), name).unwrap_throw())
|
||||
DOCUMENT.with(|d| d.create_element_ns(Some(namespace), name).unwrap())
|
||||
}
|
||||
|
||||
pub(crate) fn create_text_node(value: &str) -> Text {
|
||||
|
@ -123,67 +123,67 @@ pub(crate) fn create_empty_node() -> Node {
|
|||
|
||||
// TODO check that the attribute *actually* was changed
|
||||
pub(crate) fn set_attribute(elem: &Element, key: &str, value: &str) {
|
||||
elem.set_attribute(key, value).unwrap_throw();
|
||||
elem.set_attribute(key, value).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn set_attribute_ns(elem: &Element, namespace: &str, key: &str, value: &str) {
|
||||
elem.set_attribute_ns(Some(namespace), key, value).unwrap_throw();
|
||||
elem.set_attribute_ns(Some(namespace), key, value).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn remove_attribute(elem: &Element, key: &str) {
|
||||
elem.remove_attribute(key).unwrap_throw();
|
||||
elem.remove_attribute(key).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn remove_attribute_ns(elem: &Element, namespace: &str, key: &str) {
|
||||
elem.remove_attribute_ns(Some(namespace), key).unwrap_throw();
|
||||
elem.remove_attribute_ns(Some(namespace), key).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn add_class(classes: &DomTokenList, value: &str) {
|
||||
classes.add_1(value).unwrap_throw();
|
||||
classes.add_1(value).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn remove_class(classes: &DomTokenList, value: &str) {
|
||||
classes.remove_1(value).unwrap_throw();
|
||||
classes.remove_1(value).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn get_style(style: &CssStyleDeclaration, name: &str) -> String {
|
||||
style.get_property_value(name).unwrap_throw()
|
||||
style.get_property_value(name).unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn remove_style(style: &CssStyleDeclaration, name: &str) {
|
||||
// TODO don't return String ?
|
||||
style.remove_property(name).unwrap_throw();
|
||||
style.remove_property(name).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn set_style(style: &CssStyleDeclaration, name: &str, value: &str, important: bool) {
|
||||
let priority = if important { intern("important") } else { intern("") };
|
||||
style.set_property_with_priority(name, value, priority).unwrap_throw();
|
||||
style.set_property_with_priority(name, value, priority).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn insert_child_before(parent: &Node, child: &Node, other: &Node) {
|
||||
// TODO don't return Node ?
|
||||
parent.insert_before(child, Some(other)).unwrap_throw();
|
||||
parent.insert_before(child, Some(other)).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn replace_child(parent: &Node, child: &Node, other: &Node) {
|
||||
// TODO don't return Node ?
|
||||
parent.replace_child(child, other).unwrap_throw();
|
||||
parent.replace_child(child, other).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn append_child(parent: &Node, child: &Node) {
|
||||
// TODO don't return Node ?
|
||||
parent.append_child(child).unwrap_throw();
|
||||
parent.append_child(child).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn remove_child(parent: &Node, child: &Node) {
|
||||
// TODO don't return Node ?
|
||||
parent.remove_child(child).unwrap_throw();
|
||||
parent.remove_child(child).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn focus(elem: &HtmlElement) {
|
||||
elem.focus().unwrap_throw();
|
||||
elem.focus().unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn blur(elem: &HtmlElement) {
|
||||
elem.blur().unwrap_throw();
|
||||
elem.blur().unwrap();
|
||||
}
|
||||
|
|
12
src/dom.rs
12
src/dom.rs
|
@ -10,7 +10,7 @@ use futures_signals::signal_vec::SignalVec;
|
|||
use futures_util::FutureExt;
|
||||
use futures_channel::oneshot;
|
||||
use discard::{Discard, DiscardOnDrop};
|
||||
use wasm_bindgen::{JsValue, UnwrapThrowExt, JsCast, intern};
|
||||
use wasm_bindgen::{JsValue, JsCast, intern};
|
||||
use web_sys::{HtmlElement, Node, EventTarget, Element, CssStyleSheet, CssStyleDeclaration, ShadowRoot, ShadowRootMode, ShadowRootInit, Text};
|
||||
|
||||
use crate::bindings;
|
||||
|
@ -151,7 +151,7 @@ impl Signal for IsWindowLoaded {
|
|||
receiver,
|
||||
_event: EventListener::once(bindings::window_event_target(), "load", move |_| {
|
||||
// TODO test this
|
||||
sender.send(Some(true)).unwrap_throw();
|
||||
sender.send(Some(true)).unwrap();
|
||||
}),
|
||||
};
|
||||
|
||||
|
@ -159,7 +159,7 @@ impl Signal for IsWindowLoaded {
|
|||
}
|
||||
},
|
||||
IsWindowLoaded::Pending { ref mut receiver, .. } => {
|
||||
receiver.poll_unpin(cx).map(|x| x.unwrap_throw())
|
||||
receiver.poll_unpin(cx).map(|x| x.unwrap())
|
||||
},
|
||||
IsWindowLoaded::Done {} => {
|
||||
Poll::Ready(None)
|
||||
|
@ -264,13 +264,13 @@ impl Dom {
|
|||
#[inline]
|
||||
fn create_element<A>(name: &str) -> A where A: JsCast {
|
||||
// TODO use unchecked_into in release mode ?
|
||||
bindings::create_element(intern(name)).dyn_into().unwrap_throw()
|
||||
bindings::create_element(intern(name)).dyn_into().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn create_element_ns<A>(name: &str, namespace: &str) -> A where A: JsCast {
|
||||
// TODO use unchecked_into in release mode ?
|
||||
bindings::create_element_ns(intern(namespace), intern(name)).dyn_into().unwrap_throw()
|
||||
bindings::create_element_ns(intern(namespace), intern(name)).dyn_into().unwrap()
|
||||
}
|
||||
|
||||
|
||||
|
@ -707,7 +707,7 @@ impl<A> DomBuilder<A> where A: AsRef<Element> {
|
|||
#[inline]
|
||||
#[doc(hidden)]
|
||||
pub fn __internal_shadow_root(&self, mode: ShadowRootMode) -> DomBuilder<ShadowRoot> {
|
||||
let shadow = self.element.as_ref().attach_shadow(&ShadowRootInit::new(mode)).unwrap_throw();
|
||||
let shadow = self.element.as_ref().attach_shadow(&ShadowRootInit::new(mode)).unwrap();
|
||||
DomBuilder::new(shadow)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::traits::StaticEvent;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{EventTarget, HtmlInputElement, HtmlTextAreaElement, TouchList};
|
||||
use web_sys::{EventTarget, HtmlInputElement, HtmlTextAreaElement, TouchList, Touch};
|
||||
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
|
@ -55,8 +55,6 @@ macro_rules! make_event {
|
|||
}
|
||||
|
||||
impl $name {
|
||||
#[inline] pub fn current_target(&self) -> Option<EventTarget> { self.event.current_target() }
|
||||
|
||||
#[inline] pub fn prevent_default(&self) { self.event.prevent_default(); }
|
||||
|
||||
#[inline] pub fn stop_propagation(&self) { self.event.stop_propagation(); }
|
||||
|
@ -156,9 +154,20 @@ macro_rules! make_touch_event {
|
|||
#[inline] pub fn shift_key(&self) -> bool { self.event.shift_key() }
|
||||
#[inline] pub fn alt_key(&self) -> bool { self.event.alt_key() }
|
||||
|
||||
#[inline] pub fn changed_touches(&self) -> TouchList { self.event.changed_touches() }
|
||||
#[inline] pub fn target_touches(&self) -> TouchList { self.event.target_touches() }
|
||||
#[inline] pub fn touches(&self) -> TouchList { self.event.touches() }
|
||||
#[inline]
|
||||
pub fn changed_touches(&self) -> impl Iterator<Item = Touch> {
|
||||
TouchListIter::new(self.event.changed_touches())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn target_touches(&self) -> impl Iterator<Item = Touch> {
|
||||
TouchListIter::new(self.event.target_touches())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn touches(&self) -> impl Iterator<Item = Touch> {
|
||||
TouchListIter::new(self.event.touches())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -254,11 +263,6 @@ make_pointer_event!(PointerLeave, "pointerleave");
|
|||
make_pointer_event!(GotPointerCapture, "gotpointercapture");
|
||||
make_pointer_event!(LostPointerCapture, "lostpointercapture");
|
||||
|
||||
make_touch_event!(TouchCancel, "touchcancel");
|
||||
make_touch_event!(TouchEnd, "touchend");
|
||||
make_touch_event!(TouchMove, "touchmove");
|
||||
make_touch_event!(TouchStart, "touchstart");
|
||||
|
||||
make_keyboard_event!(KeyDown, "keydown");
|
||||
make_keyboard_event!(KeyUp, "keyup");
|
||||
|
||||
|
@ -325,3 +329,41 @@ impl Change {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
make_touch_event!(TouchCancel, "touchcancel");
|
||||
make_touch_event!(TouchEnd, "touchend");
|
||||
make_touch_event!(TouchMove, "touchmove");
|
||||
make_touch_event!(TouchStart, "touchstart");
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TouchListIter {
|
||||
list: TouchList,
|
||||
index: u32,
|
||||
length: u32,
|
||||
}
|
||||
|
||||
impl TouchListIter {
|
||||
fn new(list: TouchList) -> Self {
|
||||
Self {
|
||||
index: 0,
|
||||
length: list.length(),
|
||||
list,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for TouchListIter {
|
||||
type Item = Touch;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let index = self.index;
|
||||
|
||||
if index < self.length {
|
||||
self.index += 1;
|
||||
self.list.get(index)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#![deny(warnings)]
|
||||
|
||||
#![cfg_attr(feature = "nightly", allow(incomplete_features))]
|
||||
#![cfg_attr(feature = "nightly", feature(const_generics))]
|
||||
#![cfg_attr(feature = "nightly", feature(adt_const_params))]
|
||||
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
@ -9,7 +9,6 @@ use futures_signals::{cancelable_future, CancelableFutureHandle};
|
|||
use futures_signals::signal::{Signal, SignalExt};
|
||||
use futures_signals::signal_vec::{VecDiff, SignalVec, SignalVecExt};
|
||||
use web_sys::Node;
|
||||
use wasm_bindgen::UnwrapThrowExt;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
|
||||
use crate::bindings;
|
||||
|
@ -290,7 +289,7 @@ pub(crate) fn insert_children_signal_vec<A>(element: Node, callbacks: &mut Callb
|
|||
},
|
||||
|
||||
VecDiff::Pop {} => {
|
||||
let dom = self.children.pop().unwrap_throw();
|
||||
let dom = self.children.pop().unwrap();
|
||||
|
||||
bindings::remove_child(&self.element, &dom.element);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::mem::ManuallyDrop;
|
||||
|
||||
use wasm_bindgen::{JsCast, UnwrapThrowExt, intern};
|
||||
use wasm_bindgen::{JsCast, intern};
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use discard::Discard;
|
||||
use web_sys::{EventTarget, Event};
|
||||
|
@ -56,7 +56,7 @@ impl Drop for EventListener {
|
|||
impl Discard for EventListener {
|
||||
#[inline]
|
||||
fn discard(mut self) {
|
||||
let closure = self.closure.take().unwrap_throw();
|
||||
let closure = self.closure.take().unwrap();
|
||||
bindings::remove_event(&self.elem, &self.name, self.capture, closure.as_ref().unchecked_ref());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue