setScrollOffset method

void setScrollOffset(
  1. double offset
)

Sets horizontal scroll offset directly with boundary clamping.

Implementation

void setScrollOffset(double offset) {
  final maxScroll = (candles.length * _viewport.candleWidth).clamp(0.0, double.infinity);
  final clamped = offset.clamp(-120.0, maxScroll);
  if (_viewport.scrollOffset != clamped) {
    _viewport = _viewport.copyWith(scrollOffset: clamped);
    notifyListeners();
  }
}