share-this icon indicating copy to clipboard operation
share-this copied to clipboard

How to center tooltip?

Open hackuun opened this issue 7 years ago • 1 comments

Is there any option by any chance to center tooltip? If you look closely to Medium, they have it.

hackuun avatar Aug 17 '17 21:08 hackuun

I guess you mean you want the tooltip centered in relation to the selected area, not close to the final end of the selection.

No, at this moment there's no such option. It might be worth considering, although you can set the position of the popover as you want by defining a callback for the onOpen hook. For example:

shareThis({
  onOpen(popover) {
    popover.style.right = "";
    popover.style.maxWidth = "none";
    const range = getSelection().getRangeAt(0);
    const rect = range.getBoundingClientRect();
    for (const prop of [ "top", "left", "width", "height" ]) {
      popover.style[prop] = rect[prop] + "px";
    }
  }
});

MaxArt2501 avatar Aug 17 '17 22:08 MaxArt2501