public calcPrimaryDistance()

in src/focus/focus-by-distance.ts [29:46]


  public calcPrimaryDistance(refRect: ClientRect, dir: Button) {
    switch (dir) {
      case Button.Left:
        this.primaryDistance = refRect.left - this.rect.right;
        break;
      case Button.Right:
        this.primaryDistance = this.rect.left - refRect.right;
        break;
      case Button.Up:
        this.primaryDistance = refRect.top - this.rect.bottom;
        break;
      case Button.Down:
        this.primaryDistance = this.rect.top - refRect.bottom;
        break;
      default:
        throw new Error(`Invalid direction ${dir}`);
    }
  }