8
8
VerticalAlignment
9
9
} from './../utilities' ;
10
10
import { scaleInVerTop , scaleOutVerTop } from '../../../animations/main' ;
11
+ import { ConnectedFit } from './base-fit-position-strategy' ;
11
12
12
13
/**
13
14
* Positions the element based on the directions and start point passed in trough PositionSettings.
@@ -33,11 +34,17 @@ export class ConnectedPositioningStrategy implements IPositionStrategy {
33
34
this . settings = Object . assign ( { } , this . _defaultSettings , settings ) ;
34
35
}
35
36
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
+
36
44
/** @inheritdoc */
37
45
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 ) ;
41
48
}
42
49
43
50
/**
@@ -56,10 +63,10 @@ export class ConnectedPositioningStrategy implements IPositionStrategy {
56
63
* @param targetRect Bounding rectangle of strategy target
57
64
* @param elementRect Bounding rectangle of the element
58
65
*/
59
- protected setStyle ( element : HTMLElement , targetRect : ClientRect , elementRect : ClientRect ) {
66
+ protected setStyle ( element : HTMLElement , targetRect : ClientRect , elementRect : ClientRect , connectedFit ?: ConnectedFit ) {
60
67
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 )
63
70
} ;
64
71
const wrapperRect : ClientRect = element . parentElement . getBoundingClientRect ( ) ;
65
72
0 commit comments