<commit_before>import {Injectable} from 'angular2/core';

import {Tooltip} from './tooltip';


@Injectable()
export class TooltipService {
  private offsetX: number = 20;
  private offsetY: number = 20;
  private width: number = 250;
  private height: number = 200;

  public tooltip: Tooltip = null;
  public x: number = 0;
  public y: number = 0;
  public translateX = false;
  public translateY = false;

  show(tooltip: Tooltip) {
    this.tooltip = tooltip;
  }

  hide() {
    this.tooltip = null;
  }

  // TODO: Make tooltip change position near the "walls"(viewport).
  // UPDATE: hotfix implemented, still need fixing but now does not
  // break the app.
  follow(event: MouseEvent) {
    this.x = event.pageX + this.offsetX;
    this.y = event.pageY + this.offsetY;

    const vp = this.inViewport(event.pageX, event.pageY);
    this.translateX = vp.x;
    this.translateY = vp.y;
  }

  inViewport(x, y) {
    return {
      x: x + this.width + this.offsetX > window.innerWidth,
      y: y + this.height + this.offsetY > window.innerHeight
    }
  }
}<commit_msg>New property "padding".<commit_after>import {Injectable} from 'angular2/core';

import {Tooltip} from './tooltip';


@Injectable()
export class TooltipService {
  private offsetX: number = 20;
  private offsetY: number = 20;
  private width: number = 250;
  private height: number = 200;
  private padding: number = 20;

  public tooltip: Tooltip = null;
  public x: number = 0;
  public y: number = 0;
  public translateX = false;
  public translateY = false;

  show(tooltip: Tooltip) {
    this.tooltip = tooltip;
  }

  hide() {
    this.tooltip = null;
  }

  // TODO: Make tooltip change position near the "walls"(viewport).
  // UPDATE: hotfix implemented, still need fixing but now does not
  // break the app.
  follow(event: MouseEvent) {
    this.x = event.pageX + this.offsetX;
    this.y = event.pageY + this.offsetY;

    const vp = this.inViewport(event.pageX, event.pageY);
    this.translateX = vp.x;
    this.translateY = vp.y;
  }

  inViewport(x, y) {
    return {
      x: x + this.width + this.offsetX > window.innerWidth - this.padding,
      y: y + this.height + this.offsetY > window.innerHeight - this.padding
    }
  }
}
{'fraction_non_alphanumeric': 0.1224122412241224, 'fraction_numerical': 0.012601260126012601, 'mean_word_length': 2.9767441860465116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7649194', 'n_tokens_mistral': 786, 'n_tokens_neox': 742, 'n_words': 214}