Skip to content

Commit

Permalink
fix toolbar vertical overflow behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jul 15, 2016
1 parent a3234c9 commit 171fcd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assets/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ colorItemsPerRow = 7

.ql-hidden
display: none
.ql-out-bottom, .ql-out-top
visibility: hidden

.ql-tooltip
position: absolute
Expand Down
8 changes: 8 additions & 0 deletions ui/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ class Tooltip {
let offset = parseInt(window.getComputedStyle(this.root).marginTop);
this.quill.root.addEventListener('scroll', () => {
this.root.style.marginTop = (-1*this.quill.root.scrollTop) + offset + 'px';
this.checkBounds();
});
this.textbox = this.root.querySelector('input[type="text"]');
this.listen();
this.hide();
}

checkBounds() {
this.root.classList.toggle('ql-out-top', this.root.offsetTop <= 0);
this.root.classList.remove('ql-out-bottom');
this.root.classList.toggle('ql-out-bottom', this.root.offsetTop + this.root.offsetHeight >= this.quill.root.offsetHeight);
}

listen() {
this.textbox.addEventListener('keydown', (event) => {
if (Keyboard.match(event, 'enter')) {
Expand Down Expand Up @@ -44,6 +51,7 @@ class Tooltip {
shift = containerBounds.left - rootBounds.left;
this.root.style.left = (left + shift) + 'px';
}
this.checkBounds();
return shift;
}

Expand Down

0 comments on commit 171fcd7

Please sign in to comment.