浏览代码

Fixed: Rect.getViewportRect() returns position:absolute coordinates instead of boundingClientRect–like.

Aleksander Nowodzinski 9 年之前
父节点
当前提交
3a5038f3f2
共有 2 个文件被更改,包括 9 次插入9 次删除
  1. 5 5
      packages/ckeditor5-utils/src/dom/rect.js
  2. 4 4
      packages/ckeditor5-utils/tests/dom/rect.js

+ 5 - 5
packages/ckeditor5-utils/src/dom/rect.js

@@ -166,13 +166,13 @@ export default class Rect {
 	 * @returns {utils.dom.Rect} A viewport rect.
 	 */
 	static getViewportRect() {
-		const { scrollX, scrollY, innerWidth, innerHeight } = window;
+		const { innerWidth, innerHeight } = window;
 
 		return new Rect( {
-			top: scrollY,
-			right: innerWidth + scrollX,
-			bottom: innerHeight + scrollY,
-			left: scrollX,
+			top: 0,
+			right: innerWidth,
+			bottom: innerHeight,
+			left: 0,
 			width: innerWidth,
 			height: innerHeight
 		} );

+ 4 - 4
packages/ckeditor5-utils/tests/dom/rect.js

@@ -332,10 +332,10 @@ describe( 'Rect', () => {
 			window.innerHeight = 500;
 
 			assertRect( Rect.getViewportRect(), {
-				top: 200,
-				right: 1100,
-				bottom: 700,
-				left: 100,
+				top: 0,
+				right: 1000,
+				bottom: 500,
+				left: 0,
 				width: 1000,
 				height: 500
 			} );