Skip to content

Commit

Permalink
Fix tooltip position (codex-team#655)
Browse files Browse the repository at this point in the history
* Fix tooltip position

* Update paragraph

* Update version

* Update changelog

* Update docs/CHANGELOG.md
  • Loading branch information
gohabereg authored Mar 27, 2019
1 parent dd42adb commit 8f670dc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dist/editor.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 2.12.3

- `Fix` — Make Toolbox tooltip position font-size independent

### 2.12.2

- New *Inline Tools* — pass tool settings from configuration to Tool constructor
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.12.2",
"version": "2.12.3",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/components/modules/toolbar/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,15 @@ export default class Toolbox extends Module {
}));
}

const offset = 16;
const leftOffset = 16;
const coordinate = button.offsetLeft;
const topOffset = Math.floor(this.Editor.BlockManager.currentBlock.holder.offsetHeight / 2);

this.nodes.tooltip.innerHTML = '';
this.nodes.tooltip.appendChild(fragment);

this.nodes.tooltip.style.left = `${coordinate + offset}px`;
this.nodes.tooltip.style.left = `${coordinate + leftOffset}px`;
this.nodes.tooltip.style.transform = `translate3d(-50%, ${topOffset}px, 0)`;
this.nodes.tooltip.classList.add(this.CSS.tooltipShown);
}

Expand Down
3 changes: 1 addition & 2 deletions src/styles/toolbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

&__tooltip {
position: absolute;
top: 43px;
top: 25px;
padding: 6px 10px;
transform: translateX(-50%);
border-radius: 5px;
line-height: 21px;
opacity: 0;
Expand Down

0 comments on commit 8f670dc

Please sign in to comment.