Browse Source

Use Rect class for mention item visibility test.

Maciej Gołaszewski 6 years ago
parent
commit
d29c804eba
1 changed files with 2 additions and 4 deletions
  1. 2 4
      packages/ckeditor5-mention/src/ui/mentionsview.js

+ 2 - 4
packages/ckeditor5-mention/src/ui/mentionsview.js

@@ -9,6 +9,7 @@
 
 import View from '@ckeditor/ckeditor5-ui/src/view';
 import ListView from '@ckeditor/ckeditor5-ui/src/list/listview';
+import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
 
 import '../../theme/mentionui.css';
 
@@ -123,9 +124,6 @@ export default class MentionsView extends View {
 	// - its top boundary is inside the scrollable rect
 	// - its bottom boundary is inside the scrollable rect (the whole item must be visible)
 	_isItemVisibleInScrolledArea( item ) {
-		const isBottomLineVisible = item.element.offsetTop + item.element.clientHeight <= this.element.clientHeight;
-		const isTopLineVisible = item.element.offsetTop >= this.element.scrollTop;
-
-		return isBottomLineVisible && isTopLineVisible;
+		return new Rect( this.element ).contains( new Rect( item.element ) );
 	}
 }