wallet: chatview touch finger scroll accel/decel

This commit is contained in:
darkfi
2024-08-03 12:28:06 +02:00
parent 759af23a91
commit cb0ce5a7e7
2 changed files with 10 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
#![feature(deadline_api)]
#![feature(str_split_whitespace_remainder)]
#![feature(duration_millis_float)]
// Use these to incrementally fix warnings with cargo fix
//#![allow(warnings, unused)]

View File

@@ -203,6 +203,7 @@ fn select_nick_color(nick: &str, nick_colors: &[Color]) -> Color {
color
}
#[derive(Clone)]
struct TouchInfo {
start_scroll: f32,
start_y: f32,
@@ -567,6 +568,14 @@ impl ChatView {
}
TouchPhase::Ended => {
// Now calculate scroll acceleration
let touch_info = self.touch_info.lock().unwrap().clone();
let time = touch_info.start_instant.elapsed().as_millis_f32();
let dist = touch_y - touch_info.start_y;
let accel = self.mouse_scroll_start_accel.get() * dist / time;
self.accel.fetch_add(accel, Ordering::Relaxed);
self.motion_cv.notify();
}
TouchPhase::Cancelled => {}
}