|
@@ -29,7 +29,10 @@ use sled_overlay::sled;
|
|
|
use std::{
|
|
use std::{
|
|
|
hash::{DefaultHasher, Hash, Hasher},
|
|
hash::{DefaultHasher, Hash, Hasher},
|
|
|
io::Cursor,
|
|
io::Cursor,
|
|
|
- sync::{atomic::Ordering, Arc, Mutex as SyncMutex, Weak},
|
|
|
|
|
|
|
+ sync::{
|
|
|
|
|
+ atomic::{AtomicBool, Ordering},
|
|
|
|
|
+ Arc, Mutex as SyncMutex, Weak,
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
mod page;
|
|
mod page;
|
|
@@ -122,6 +125,7 @@ pub struct ChatView {
|
|
|
mouse_pos: SyncMutex<Point>,
|
|
mouse_pos: SyncMutex<Point>,
|
|
|
/// Touch scrolling
|
|
/// Touch scrolling
|
|
|
touch_info: SyncMutex<TouchInfo>,
|
|
touch_info: SyncMutex<TouchInfo>,
|
|
|
|
|
+ touch_is_updating: AtomicBool,
|
|
|
|
|
|
|
|
rect: PropertyPtr,
|
|
rect: PropertyPtr,
|
|
|
scroll: PropertyFloat32,
|
|
scroll: PropertyFloat32,
|
|
@@ -261,6 +265,7 @@ impl ChatView {
|
|
|
|
|
|
|
|
mouse_pos: SyncMutex::new(Point::from([0., 0.])),
|
|
mouse_pos: SyncMutex::new(Point::from([0., 0.])),
|
|
|
touch_info: SyncMutex::new(TouchInfo::new()),
|
|
touch_info: SyncMutex::new(TouchInfo::new()),
|
|
|
|
|
+ touch_is_updating: AtomicBool::new(false),
|
|
|
|
|
|
|
|
rect,
|
|
rect,
|
|
|
scroll,
|
|
scroll,
|
|
@@ -447,7 +452,10 @@ impl ChatView {
|
|
|
touch_info.last_y = touch_y;
|
|
touch_info.last_y = touch_y;
|
|
|
}
|
|
}
|
|
|
TouchPhase::Moved => {
|
|
TouchPhase::Moved => {
|
|
|
- let instant = std::time::Instant::now();
|
|
|
|
|
|
|
+ if !self.touch_is_updating.fetch_or(true, Ordering::Relaxed) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let (start_scroll, start_y, do_update) = {
|
|
let (start_scroll, start_y, do_update) = {
|
|
|
let mut touch_info = self.touch_info.lock().unwrap();
|
|
let mut touch_info = self.touch_info.lock().unwrap();
|
|
|
touch_info.last_y = touch_y;
|
|
touch_info.last_y = touch_y;
|
|
@@ -470,6 +478,8 @@ impl ChatView {
|
|
|
if do_update {
|
|
if do_update {
|
|
|
self.scrollview(scroll).await;
|
|
self.scrollview(scroll).await;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ self.touch_is_updating.store(true, Ordering::Relaxed);
|
|
|
}
|
|
}
|
|
|
TouchPhase::Ended => {
|
|
TouchPhase::Ended => {
|
|
|
// Now calculate scroll acceleration
|
|
// Now calculate scroll acceleration
|