private static double getDelta(@NotNull JScrollBar bar, @NotNull MouseWheelEvent event, double animationTargetValue) {
    double rotation = event.getPreciseWheelRotation();
    int direction = rotation < 0 ? -1 : 1;

    if (event.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
      return direction * bar.getBlockIncrement(direction);
    }

    if (event.getSource() instanceof JScrollPane) {
      JViewport viewport = ((JScrollPane)event.getSource()).getViewport();
      if (viewport.getView() instanceof Scrollable scrollable) {
        int orientation = bar.getOrientation();
        boolean isVertical = orientation == Adjustable.VERTICAL;
        int scroll = abs(event.getUnitsToScroll());
        Rectangle rect = viewport.getViewRect();
        int delta = 0;
        if (!Double.isNaN(animationTargetValue)) {
          if (isVertical) {
            rect.y = (int)animationTargetValue;
          }
          else {
            rect.x = (int)animationTargetValue;
          }
        }
        for (int i = 0; i < scroll; i++) {
          int increment = max(scrollable.getScrollableUnitIncrement(rect, orientation, direction), 0) * direction;
          if (isVertical) {
            rect.y += increment;
          }
          else {
            rect.x += increment;
          }
          delta += increment;
        }
        return delta;
      }
    }

    int increment = bar.getUnitIncrement(direction);
    int delta = increment * event.getUnitsToScroll();
    return delta == 0 ? rotation : delta;
  }
private static double getDelta(@NotNull JScrollBar bar, @NotNull MouseWheelEvent event, double animationTargetValue)