show method

void show ()

Show the tooltip.

Implementation

void show() {
  if (!hasContent || !_enabled)
    return;

  final QueryEvent e = new QueryEvent('show.bs.$_type');
  $element.triggerEvent(e);
  if (e.defaultPrevented)
    return;

  _setContent();
  if (animation)
    tip.classes.add('fade');

  final String placement = _placement(element) ?? _placementDefault;

  tip.remove();
  tip.style.top = tip.style.left = '0';
  tip.style.display = 'block';

  if (container != null)
    $(tip).appendTo(container);
  else
    $element.after(tip);

  final Rectangle pos = _position;
  final int actualWidth = tip.offsetWidth;
  final int actualHeight = tip.offsetHeight;
  int top, left;

  switch (placement) {
    case 'bottom':
      top = (pos.top + pos.height).round();
      left = (pos.left + (pos.width - actualWidth) / 2).round();
      break;
    case 'top':
      top = pos.top.round() - actualHeight;
      left = (pos.left + (pos.width - actualWidth) / 2).round();
      break;
    case 'left':
      top = (pos.top + (pos.height - actualHeight) / 2).round();
      left = pos.left.round() - actualWidth;
      break;
    case 'right':
      top = (pos.top + (pos.height - actualHeight) / 2).round();
      left = (pos.left + pos.width).round();
      break;
  }
  _applyPlacement(top, left, placement);
  $element.trigger('shown.bs.$_type');

}