getSubMenuOpenPercent method

double getSubMenuOpenPercent()

Get how many percents submenu is moved from close state location to the open state location

Implementation

double getSubMenuOpenPercent() {
  double menuRight = actualMenuRight;
  double subMenuStart = 0;
  double subMenuEnd = 0;

  if (widget.menuLocation == MenuLocation.left) {
    subMenuStart = menuRight - getActualSubMenuWidth();
    subMenuEnd = menuRight;
  } else {
    subMenuStart = getMenuX();
    subMenuEnd = getMenuX() - getActualSubMenuWidth();
  }

  double subMenuCurrentX = getSubMenuX();
  double subMenuStartToEndDistance = (subMenuEnd - subMenuStart).abs();
  double subMenuStartToCurrentXDistance =
      (subMenuStart - subMenuCurrentX).abs();

  if (subMenuStartToEndDistance == 0) {
    return 0;
  } else {
    return subMenuStartToCurrentXDistance / subMenuStartToEndDistance;
  }
}