From cc6b6bf595f1246ee3ff39d341a1e570b336361b Mon Sep 17 00:00:00 2001 From: Ludwig Schubert Date: Mon, 17 Dec 2018 12:59:38 -0800 Subject: [PATCH] Fix #95 in Chrome 69+, Safari, Firefox by reverting to JS based tooltip positioning. Also DRYs some styles --- src/components/d-cite.js | 11 +++++------ src/components/d-footnote.js | 8 +------- src/components/d-hover-box.js | 13 ++++++++++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/d-cite.js b/src/components/d-cite.js index bf03a6e..48917af 100644 --- a/src/components/d-cite.js +++ b/src/components/d-cite.js @@ -19,7 +19,7 @@ const T = Template('d-cite', ` @@ -117,11 +121,14 @@ export class HoverBox extends T(HTMLElement) { show(position) { this.visible = true; this.style.display = 'block'; + // 10px extra offset from element + this.style.top = Math.round(position[1] + 10) + 'px'; } showAtNode(node) { + // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop const bbox = node.getBoundingClientRect(); - this.show([bbox.right, bbox.bottom]); + this.show([node.offsetLeft + bbox.width, node.offsetTop + bbox.height]); } hide() {