mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
wallet: chatview touch finger scroll accel/decel
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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 => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user