From 488b7795eb5c1f435cdbaeea36b3ed69d0370560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Wed, 2 Oct 2019 15:47:18 +0300 Subject: [PATCH] Typewriter: use DOMRect.top to fix for Edge (#17707) --- .../block-editor/src/components/typewriter/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/typewriter/index.js b/packages/block-editor/src/components/typewriter/index.js index cb17e38e54920..7600b2cd8747c 100644 --- a/packages/block-editor/src/components/typewriter/index.js +++ b/packages/block-editor/src/components/typewriter/index.js @@ -129,7 +129,7 @@ class Typewriter extends Component { return; } - const diff = currentCaretRect.y - this.caretRect.y; + const diff = currentCaretRect.top - this.caretRect.top; if ( diff === 0 ) { return; @@ -148,10 +148,10 @@ class Typewriter extends Component { scrollContainer.scrollTop; const scrollContainerY = windowScroll ? 0 : - scrollContainer.getBoundingClientRect().y; + scrollContainer.getBoundingClientRect().top; const relativeScrollPosition = windowScroll ? - this.caretRect.y / window.innerHeight : - ( this.caretRect.y - scrollContainerY ) / + this.caretRect.top / window.innerHeight : + ( this.caretRect.top - scrollContainerY ) / ( window.innerHeight - scrollContainerY ); // If the scroll position is at the start, the active editable element @@ -178,10 +178,10 @@ class Typewriter extends Component { // view. if ( // The caret is under the lower fold. - this.caretRect.y + this.caretRect.height > + this.caretRect.top + this.caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold. - this.caretRect.y < scrollContainerY + this.caretRect.top < scrollContainerY ) { // Reset the caret position to maintain. this.caretRect = currentCaretRect;