瀏覽代碼

Allowed getOptimalPosition helper's limiter as a Function.

Aleksander Nowodzinski 8 年之前
父節點
當前提交
73daedbf77
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      packages/ckeditor5-utils/src/dom/position.js

+ 8 - 2
packages/ckeditor5-utils/src/dom/position.js

@@ -82,6 +82,12 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn
 		target = target();
 	}
 
+	// If the {@link module:utils/dom/position~Options#limiter} is a function, use what it returns.
+	// https://github.com/ckeditor/ckeditor5-ui/issues/260
+	if ( typeof limiter == 'function' ) {
+		limiter = limiter();
+	}
+
 	const positionedElementAncestor = getPositionedAncestor( element.parentElement );
 	const elementRect = new Rect( element );
 	const targetRect = new Rect( target );
@@ -261,7 +267,7 @@ function getAbsoluteRectCoordinates( { left, top } ) {
 /**
  * Target with respect to which the `element` is to be positioned.
  *
- * @member {HTMLElement|Range|ClientRect|Function} #target
+ * @member {HTMLElement|Range|ClientRect|Rect|Function} #target
  */
 
 /**
@@ -275,7 +281,7 @@ function getAbsoluteRectCoordinates( { left, top } ) {
  * When set, the algorithm will chose position which fits the most in the
  * limiter's bounding rect.
  *
- * @member {HTMLElement|Range|ClientRect} #limiter
+ * @member {HTMLElement|Range|ClientRect|Rect|Function} #limiter
  */
 
 /**