88 VerticalAlignment
99} from './../utilities' ;
1010import { scaleInVerTop , scaleOutVerTop } from '../../../animations/main' ;
11+ import { ConnectedFit } from './base-fit-position-strategy' ;
1112
1213/**
1314 * Positions the element based on the directions and start point passed in trough PositionSettings.
@@ -33,11 +34,17 @@ export class ConnectedPositioningStrategy implements IPositionStrategy {
3334 this . settings = Object . assign ( { } , this . _defaultSettings , settings ) ;
3435 }
3536
37+ protected calculateElementRectangles ( contentElement ) : { targetRect : ClientRect , elementRect : ClientRect } {
38+ return {
39+ targetRect : Util . getTargetRect ( this . settings ) ,
40+ elementRect : contentElement . getBoundingClientRect ( ) as ClientRect
41+ } ;
42+ }
43+
3644 /** @inheritdoc */
3745 position ( contentElement : HTMLElement , size : Size , document ?: Document , initialCall ?: boolean ) : void {
38- const targetRect = Util . getTargetRect ( this . settings ) ;
39- const contentElementRect = contentElement . getBoundingClientRect ( ) ;
40- this . setStyle ( contentElement , targetRect , contentElementRect ) ;
46+ const rects = this . calculateElementRectangles ( contentElement ) ;
47+ this . setStyle ( contentElement , rects . targetRect , rects . elementRect ) ;
4148 }
4249
4350 /**
@@ -56,10 +63,10 @@ export class ConnectedPositioningStrategy implements IPositionStrategy {
5663 * @param targetRect Bounding rectangle of strategy target
5764 * @param elementRect Bounding rectangle of the element
5865 */
59- protected setStyle ( element : HTMLElement , targetRect : ClientRect , elementRect : ClientRect ) {
66+ protected setStyle ( element : HTMLElement , targetRect : ClientRect , elementRect : ClientRect , connectedFit ?: ConnectedFit ) {
6067 const startPoint : Point = {
61- x : targetRect . right + targetRect . width * this . settings . horizontalStartPoint ,
62- y : targetRect . bottom + targetRect . height * this . settings . verticalStartPoint ,
68+ x : targetRect . right + targetRect . width * this . settings . horizontalStartPoint + ( connectedFit ? connectedFit . xOffset : 0 ) ,
69+ y : targetRect . bottom + targetRect . height * this . settings . verticalStartPoint + ( connectedFit ? connectedFit . yOffset : 0 )
6370 } ;
6471 const wrapperRect : ClientRect = element . parentElement . getBoundingClientRect ( ) ;
6572
0 commit comments