scrollXListener method

void scrollXListener()

Implementation

void scrollXListener() {
  assert(scrollListener != null);
  // If scroll is happening, that element has been unmounted, prevent null usage.
  if (scrollOffsetX != null) {
    if (DebugFlags.debugLogScrollableEnabled) {
      final double maxX = math.max(0.0, (_scrollableSize?.width ?? 0) - (_viewportSize?.width ?? 0));
      renderingLogger.finer('[Overflow-Scroll] <${renderStyle.target.tagName.toLowerCase()}> X pixels='
          '${scrollOffsetX!.pixels.toStringAsFixed(2)} max=${maxX.toStringAsFixed(2)}');
    }
    final AxisDirection dir = (renderStyle.direction == TextDirection.rtl) ? AxisDirection.left : AxisDirection.right;
    scrollListener!(scrollOffsetX!.pixels, dir);
    if (DebugFlags.debugLogSemanticsEnabled || DebugFlags.debugLogScrollableEnabled) {
      debugPrint('[webf][a11y][scroll] ${renderStyle.target} '
          'scrollX=${scrollOffsetX!.pixels.toStringAsFixed(2)} '
          'viewport=${_viewportSize?.width.toStringAsFixed(1) ?? '?'} '
          'content=${_scrollableSize?.width.toStringAsFixed(1) ?? '?'} '
          '→ markNeedsSemanticsUpdate');
    }
    // Keep semantics tree in sync with new scroll offset so accessibility
    // focus/geometry follows the visible content after programmatic scrolls.
    markNeedsSemanticsUpdate();
    markNeedsPaint();
  }
}