8
0
Просмотр исходного кода

Aligned dom/position and dom/scroll modules to the latest Rect class API.

Aleksander Nowodzinski 8 лет назад
Родитель
Сommit
2259ba4a49

+ 1 - 1
packages/ckeditor5-utils/src/dom/position.js

@@ -95,7 +95,7 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn
 		[ name, bestPosition ] = getPosition( positions[ 0 ], targetRect, elementRect );
 	} else {
 		const limiterRect = limiter && new Rect( limiter ).getVisible();
-		const viewportRect = fitInViewport && Rect.getViewportRect();
+		const viewportRect = fitInViewport && new Rect( global.window );
 
 		[ name, bestPosition ] =
 			getBestPosition( positions, targetRect, elementRect, limiterRect, viewportRect ) ||

+ 2 - 6
packages/ckeditor5-utils/src/dom/scroll.js

@@ -32,9 +32,7 @@ function scrollViewportToShowTarget( { target, viewportOffset = 0 } ) {
 	const targetRect = new Rect( target );
 	const targetShiftedDownRect = targetRect.clone().moveBy( 0, viewportOffset );
 	const targetShiftedUpRect = targetRect.clone().moveBy( 0, -viewportOffset );
-	const viewportRect = Rect.getViewportRect( {
-		excludeScrollbars: true
-	} );
+	const viewportRect = new Rect( global.window ).excludeScrollbarsAndBorders();
 
 	// Avoid the situation where the caret is still in the viewport, but totally
 	// at the edge. If it moved beyond the viewport in the next action e.g. due to enter,
@@ -92,9 +90,7 @@ function scrollAncestorsToShowTarget( target ) {
 		}
 
 		targetRect = new Rect( target );
-		parentRect = new Rect( parent, {
-			excludeScrollbarsAndBorders: true
-		} );
+		parentRect = new Rect( parent ).excludeScrollbarsAndBorders();
 
 		if ( !parentRect.contains( targetRect ) ) {
 			scrollAncestorToShowTarget( { targetRect, parent, parentRect } );