handleMouseEvent method
Handles track clicks or dragging of the thumb to update the scroll offset.
Implementation
void handleMouseEvent(MouseEvent event, int localX, int localY) {
if (_lastArea == null) return;
final trackHeight = direction == LayoutDirection.vertical
? _lastArea!.height
: _lastArea!.width;
final total = _totalExtent;
final view = _viewportExtent;
if (trackHeight <= 0 || total <= 0) return;
final mousePos = direction == LayoutDirection.vertical ? localY : localX;
final double clickRatio = (mousePos / trackHeight).clamp(0.0, 1.0);
final int maxScrollOffset = total - view;
final int newOffset = (clickRatio * total).round().clamp(
0,
maxScrollOffset > 0 ? maxScrollOffset : 0,
);
_updateScrollOffset(newOffset);
}