onHover method

void onHover(
  1. dynamic tapDx,
  2. dynamic tapDy
)

called when the mouse is hovered over the widget

Implementation

void onHover(tapDx, tapDy) {
  {
    awayAnimationController = AnimationController(
        duration: widget.awayAnimationDuration, vsync: this);
    awayAnimationController.reset();

    double noAnimationDistance = 0;
    for (int index = 0; index < offsets.length; index++) {
      noAnimationDistance = sqrt(
          ((tapDx - offsets[index].dx) * (tapDx - offsets[index].dx)) +
              ((tapDy - offsets[index].dy) * (tapDy - offsets[index].dy)));

      if (noAnimationDistance < widget.hoverRadius) {
        setState(() {
          if (hoverIndex.length >
              (widget.numberOfParticles * 0.1).floor() + 1) {
            hoverIndex.removeAt(0);
          }
          hoverIndex.add(index);
        });
      }
    }
  }
}