mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibGUI: Use cursor position when calculating autoscroll delta
Autoscroll delta now takes into account the cursor position relative to the widget inner rect height to allow for faster rubber band autoscrolling.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
064b7a6216
commit
214eaebe73
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/AhmedTheGeek 🔰 Commit: https://github.com/SerenityOS/serenity/commit/214eaebe73 Pull-request: https://github.com/SerenityOS/serenity/pull/18714 Issue: https://github.com/SerenityOS/serenity/issues/18398 Reviewed-by: https://github.com/gmta ✅
@@ -333,9 +333,9 @@ Gfx::IntPoint AbstractScrollableWidget::automatic_scroll_delta_from_position(Gfx
|
||||
Gfx::IntPoint delta { 0, 0 };
|
||||
|
||||
if (pos.y() < m_autoscroll_threshold)
|
||||
delta.set_y(clamp(-(m_autoscroll_threshold - pos.y()), -m_autoscroll_threshold, 0));
|
||||
delta.set_y(AK::min(pos.y() - m_autoscroll_threshold, 0));
|
||||
else if (pos.y() > widget_inner_rect().height() - m_autoscroll_threshold)
|
||||
delta.set_y(clamp(m_autoscroll_threshold - (widget_inner_rect().height() - pos.y()), 0, m_autoscroll_threshold));
|
||||
delta.set_y(AK::max(pos.y() + m_autoscroll_threshold - widget_inner_rect().height(), 0));
|
||||
|
||||
if (pos.x() < m_autoscroll_threshold)
|
||||
delta.set_x(clamp(-(m_autoscroll_threshold - pos.x()), -m_autoscroll_threshold, 0));
|
||||
|
||||
Reference in New Issue
Block a user