Skip to content

Commit

Permalink
fix: fix link right align incomplete display
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Sep 17, 2019
1 parent 5073b55 commit c124e47
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ui/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ class Tooltip {

position(reference) {
let left = reference.left + reference.width / 2 - this.root.offsetWidth / 2;
const quillBounds = this.quill.root.getBoundingClientRect();
const containerBounds = this.boundsContainer.getBoundingClientRect();
const rootBounds = this.root.getBoundingClientRect();
if (left < 0) {
left = 8;
}
if (left > quillBounds.width - rootBounds.width - 8) {
left = quillBounds.width - rootBounds.width - 8;
}
// root.scrollTop should be 0 if scrollContainer !== root
const top = reference.bottom + this.quill.root.scrollTop;
this.root.style.left = `${left}px`;
this.root.style.top = `${top}px`;
this.root.classList.remove('ql-flip');
const containerBounds = this.boundsContainer.getBoundingClientRect();
const rootBounds = this.root.getBoundingClientRect();
let shift = 0;
if (rootBounds.right > containerBounds.right) {
shift = containerBounds.right - rootBounds.right;
Expand Down

0 comments on commit c124e47

Please sign in to comment.