(
&mut self,
enable_drag_scrolling: bool,
scroll_delta: Vector2,
delta_time: f32,
touch_input_active: bool,
)
| 5396 | const SCROLL_VELOCITY_SMOOTHING: f32 = 0.4; // EMA factor for velocity tracking |
| 5397 | |
| 5398 | pub fn update_scroll_containers( |
| 5399 | &mut self, |
| 5400 | enable_drag_scrolling: bool, |
| 5401 | scroll_delta: Vector2, |
| 5402 | delta_time: f32, |
| 5403 | touch_input_active: bool, |
| 5404 | ) { |
| 5405 | let pointer = self.pointer_info.position; |
| 5406 | let dt = delta_time.max(0.0001); // Guard against zero/negative dt |
| 5407 | |
| 5408 | // Remove containers that weren't open this frame, reset flag for next frame |
| 5409 | let mut i = 0; |
| 5410 | while i < self.scroll_container_datas.len() { |
| 5411 | if !self.scroll_container_datas[i].open_this_frame { |
| 5412 | self.scroll_container_datas.swap_remove(i); |
| 5413 | continue; |
| 5414 | } |
| 5415 | self.scroll_container_datas[i].open_this_frame = false; |
| 5416 | i += 1; |
| 5417 | } |
| 5418 | |
| 5419 | for scd in &mut self.scroll_container_datas { |
| 5420 | scd.scrollbar_activity_this_frame = false; |
| 5421 | } |
| 5422 | |
| 5423 | // --- Drag scrolling --- |
| 5424 | if enable_drag_scrolling { |
| 5425 | let pointer_state = self.pointer_info.state; |
| 5426 | |
| 5427 | match pointer_state { |
| 5428 | PointerDataInteractionState::PressedThisFrame => { |
| 5429 | // Find the deepest scroll container under the pointer and start drag |
| 5430 | let mut best: Option<usize> = None; |
| 5431 | for si in 0..self.scroll_container_datas.len() { |
| 5432 | let scd = &self.scroll_container_datas[si]; |
| 5433 | let bb = scd.bounding_box; |
| 5434 | if pointer.x >= bb.x |
| 5435 | && pointer.x <= bb.x + bb.width |
| 5436 | && pointer.y >= bb.y |
| 5437 | && pointer.y <= bb.y + bb.height |
| 5438 | { |
| 5439 | best = Some(si); |
| 5440 | } |
| 5441 | } |
| 5442 | if let Some(si) = best { |
| 5443 | let scd = &mut self.scroll_container_datas[si]; |
| 5444 | scd.scroll_momentum = Vector2::default(); |
| 5445 | scd.previous_delta = Vector2::default(); |
| 5446 | |
| 5447 | scd.pointer_scroll_active = false; |
| 5448 | scd.scrollbar_thumb_drag_active_x = false; |
| 5449 | scd.scrollbar_thumb_drag_active_y = false; |
| 5450 | |
| 5451 | let mut started_thumb_drag = false; |
| 5452 | if let Some(scrollbar_cfg) = scd.scrollbar { |
| 5453 | let alpha = scrollbar_visibility_alpha(scrollbar_cfg, scd.scrollbar_idle_frames); |
| 5454 | if alpha > 0.0 { |
| 5455 | if scd.scroll_y_enabled { |
nothing calls this directly
no test coverage detected