From 4fa1e145f5b6a685d52c4aa373cd266e9b9ec4ed Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Sun, 18 Apr 2021 14:33:19 +0200 Subject: [PATCH] Enhancements to editor auto-position --- src/editor/setPosition.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/editor/setPosition.js b/src/editor/setPosition.js index 02d9c1c..fe7fb9f 100644 --- a/src/editor/setPosition.js +++ b/src/editor/setPosition.js @@ -32,6 +32,14 @@ const setPosition = (wrapperEl, editorEl, selectedEl) => { editorEl.style.top = 'auto'; editorEl.style.bottom = `${containerHeight - annotationTop}px`; } + + // Check if vertical flipping helped, push down if not + const currentOrientation = editorEl.children[1].getBoundingClientRect(); + if (currentOrientation.top < 0) { + editorEl.style.top = `${-containerBounds.top}px`; + editorEl.style.bottom = 'auto'; + } + } export default setPosition;