@@ -120,8 +120,7 @@ describe('FlexibleConnectedPositionStrategy', () => {
120
120
document . body . appendChild ( originElement ) ;
121
121
positionStrategy = overlay . position ( )
122
122
. flexibleConnectedTo ( new ElementRef ( originElement ) )
123
- . withFlexibleHeight ( false )
124
- . withFlexibleWidth ( false )
123
+ . withFlexibleDimensions ( false )
125
124
. withPush ( false ) ;
126
125
} ) ;
127
126
@@ -865,8 +864,7 @@ describe('FlexibleConnectedPositionStrategy', () => {
865
864
document . body . appendChild ( originElement ) ;
866
865
positionStrategy = overlay . position ( )
867
866
. flexibleConnectedTo ( new ElementRef ( originElement ) )
868
- . withFlexibleHeight ( false )
869
- . withFlexibleWidth ( false )
867
+ . withFlexibleDimensions ( false )
870
868
. withPush ( ) ;
871
869
} ) ;
872
870
@@ -1003,8 +1001,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1003
1001
1004
1002
it ( 'should align the overlay to `flex-start` when the content is flowing to the right' , ( ) => {
1005
1003
positionStrategy
1006
- . withFlexibleWidth ( )
1007
- . withFlexibleHeight ( )
1004
+ . withFlexibleDimensions ( )
1005
+ . withPush ( false )
1008
1006
. withPositions ( [ {
1009
1007
overlayY : 'top' ,
1010
1008
overlayX : 'start' ,
@@ -1014,13 +1012,13 @@ describe('FlexibleConnectedPositionStrategy', () => {
1014
1012
1015
1013
attachOverlay ( { positionStrategy} ) ;
1016
1014
1017
- expect ( overlayRef . overlayElement . style . justifyContent ) . toBe ( 'flex-start' ) ;
1015
+ expect ( overlayRef . hostElement . style . alignItems ) . toBe ( 'flex-start' ) ;
1018
1016
} ) ;
1019
1017
1020
1018
it ( 'should align the overlay to `flex-end` when the content is flowing to the left' , ( ) => {
1021
1019
positionStrategy
1022
- . withFlexibleWidth ( )
1023
- . withFlexibleHeight ( )
1020
+ . withFlexibleDimensions ( )
1021
+ . withPush ( false )
1024
1022
. withPositions ( [ {
1025
1023
overlayY : 'top' ,
1026
1024
overlayX : 'end' ,
@@ -1030,13 +1028,13 @@ describe('FlexibleConnectedPositionStrategy', () => {
1030
1028
1031
1029
attachOverlay ( { positionStrategy} ) ;
1032
1030
1033
- expect ( overlayRef . overlayElement . style . justifyContent ) . toBe ( 'flex-end' ) ;
1031
+ expect ( overlayRef . hostElement . style . alignItems ) . toBe ( 'flex-end' ) ;
1034
1032
} ) ;
1035
1033
1036
1034
it ( 'should align the overlay to `center` when the content is centered' , ( ) => {
1037
1035
positionStrategy
1038
- . withFlexibleWidth ( )
1039
- . withFlexibleHeight ( )
1036
+ . withFlexibleDimensions ( )
1037
+ . withPush ( false )
1040
1038
. withPositions ( [ {
1041
1039
overlayY : 'top' ,
1042
1040
overlayX : 'center' ,
@@ -1046,48 +1044,48 @@ describe('FlexibleConnectedPositionStrategy', () => {
1046
1044
1047
1045
attachOverlay ( { positionStrategy} ) ;
1048
1046
1049
- expect ( overlayRef . overlayElement . style . justifyContent ) . toBe ( 'center' ) ;
1047
+ expect ( overlayRef . hostElement . style . alignItems ) . toBe ( 'center' ) ;
1050
1048
} ) ;
1051
1049
1052
- // TODO(crisbeto): investigate failure in older Safari
1053
- // it('should support offsets when centering', () => {
1054
- // originElement.style.top = '200px';
1055
- // originElement.style.left = '200px';
1056
-
1057
- // positionStrategy
1058
- // .withFlexibleWidth()
1059
- // .withFlexibleHeight()
1060
- // .withPositions([{
1061
- // overlayY: 'center',
1062
- // overlayX: 'center',
1063
- // originY: 'center',
1064
- // originX: 'center',
1065
- // offsetY: 20,
1066
- // offsetX: -15
1067
- // }]);
1068
-
1069
- // attachOverlay({positionStrategy});
1070
-
1071
- // const originRect = originElement.getBoundingClientRect();
1072
- // const originCenterY = originRect.top + (ORIGIN_HEIGHT / 2);
1073
- // const originCenterX = originRect.left + (ORIGIN_WIDTH / 2);
1074
-
1075
- // const overlayRect = overlayRef.overlayElement.getBoundingClientRect();
1076
- // const overlayCenterY = overlayRect.top + (OVERLAY_HEIGHT / 2);
1077
- // const overlayCenterX = overlayRect.left + (OVERLAY_WIDTH / 2);
1078
-
1079
- // expect(overlayRef.overlayElement.style.transform)
1080
- // .toBe('translateX(-15px) translateY(20px)');
1081
- // expect(Math.floor(overlayCenterY)).toBe(Math.floor(originCenterY) + 20);
1082
- // expect(Math.floor(overlayCenterX)).toBe(Math.floor(originCenterX) - 15);
1083
- // });
1050
+ it ( 'should support offsets when centering' , ( ) => {
1051
+ originElement . style . top = '200px' ;
1052
+ originElement . style . left = '200px' ;
1053
+
1054
+ positionStrategy
1055
+ . withFlexibleDimensions ( )
1056
+ . withPush ( false )
1057
+ . withPositions ( [ {
1058
+ overlayY : 'center' ,
1059
+ overlayX : 'center' ,
1060
+ originY : 'center' ,
1061
+ originX : 'center' ,
1062
+ offsetY : 20 ,
1063
+ offsetX : - 15
1064
+ } ] ) ;
1065
+
1066
+ attachOverlay ( { positionStrategy} ) ;
1067
+
1068
+ const originRect = originElement . getBoundingClientRect ( ) ;
1069
+ const originCenterX = originRect . left + ( DEFAULT_WIDTH / 2 ) ;
1070
+ const originCenterY = originRect . top + ( DEFAULT_HEIGHT / 2 ) ;
1071
+
1072
+ const overlayRect = overlayRef . overlayElement . getBoundingClientRect ( ) ;
1073
+ const overlayCenterY = overlayRect . top + ( OVERLAY_HEIGHT / 2 ) ;
1074
+ const overlayCenterX = overlayRect . left + ( OVERLAY_WIDTH / 2 ) ;
1075
+
1076
+ expect ( overlayRef . overlayElement . style . transform )
1077
+ . toBe ( 'translateX(-15px) translateY(20px)' ) ;
1078
+ expect ( Math . floor ( overlayCenterY ) ) . toBe ( Math . floor ( originCenterY ) + 20 ) ;
1079
+ expect ( Math . floor ( overlayCenterX ) ) . toBe ( Math . floor ( originCenterX ) - 15 ) ;
1080
+ } ) ;
1084
1081
1085
1082
it ( 'should become scrollable when it hits the viewport edge with a flexible height' , ( ) => {
1086
1083
originElement . style . left = '200px' ;
1087
1084
originElement . style . bottom = `${ OVERLAY_HEIGHT - 10 } px` ;
1088
1085
1089
1086
positionStrategy
1090
- . withFlexibleHeight ( )
1087
+ . withFlexibleDimensions ( )
1088
+ . withPush ( false )
1091
1089
. withPositions ( [ {
1092
1090
overlayY : 'top' ,
1093
1091
overlayX : 'start' ,
@@ -1107,7 +1105,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1107
1105
originElement . style . right = '-20px' ;
1108
1106
1109
1107
positionStrategy
1110
- . withFlexibleWidth ( )
1108
+ . withFlexibleDimensions ( )
1109
+ . withPush ( false )
1111
1110
. withPositions ( [ {
1112
1111
overlayY : 'top' ,
1113
1112
overlayX : 'start' ,
@@ -1127,7 +1126,7 @@ describe('FlexibleConnectedPositionStrategy', () => {
1127
1126
originElement . style . bottom = `${ OVERLAY_HEIGHT - 10 } px` ;
1128
1127
1129
1128
positionStrategy
1130
- . withFlexibleHeight ( )
1129
+ . withFlexibleDimensions ( )
1131
1130
. withPositions ( [ {
1132
1131
overlayY : 'top' ,
1133
1132
overlayX : 'start' ,
@@ -1149,7 +1148,7 @@ describe('FlexibleConnectedPositionStrategy', () => {
1149
1148
originElement . style . right = '-20px' ;
1150
1149
1151
1150
positionStrategy
1152
- . withFlexibleWidth ( )
1151
+ . withFlexibleDimensions ( )
1153
1152
. withPositions ( [ {
1154
1153
overlayY : 'top' ,
1155
1154
overlayX : 'start' ,
@@ -1171,7 +1170,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1171
1170
originElement . style . right = '25px' ;
1172
1171
1173
1172
positionStrategy
1174
- . withFlexibleWidth ( )
1173
+ . withFlexibleDimensions ( )
1174
+ . withPush ( false )
1175
1175
. withPositions ( [
1176
1176
{
1177
1177
originX : 'end' ,
@@ -1202,7 +1202,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1202
1202
originElement . style . bottom = `${ OVERLAY_HEIGHT - 10 } px` ;
1203
1203
1204
1204
positionStrategy
1205
- . withFlexibleHeight ( )
1205
+ . withFlexibleDimensions ( )
1206
+ . withPush ( false )
1206
1207
. withGrowAfterOpen ( )
1207
1208
. withPositions ( [ {
1208
1209
overlayY : 'top' ,
@@ -1239,7 +1240,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1239
1240
window . scroll ( 0 , 50 ) ;
1240
1241
1241
1242
positionStrategy
1242
- . withFlexibleHeight ( )
1243
+ . withFlexibleDimensions ( )
1244
+ . withPush ( false )
1243
1245
. withPositions ( [ {
1244
1246
overlayY : 'bottom' ,
1245
1247
overlayX : 'start' ,
@@ -1257,14 +1259,15 @@ describe('FlexibleConnectedPositionStrategy', () => {
1257
1259
window . scroll ( 0 , 0 ) ;
1258
1260
document . body . removeChild ( veryLargeElement ) ;
1259
1261
} ) ;
1262
+
1260
1263
it ( 'should set the proper styles when the `bottom` value is exactly zero' , ( ) => {
1261
1264
originElement . style . position = 'fixed' ;
1262
1265
originElement . style . bottom = '0' ;
1263
1266
originElement . style . left = '200px' ;
1264
1267
1265
1268
positionStrategy
1266
- . withFlexibleWidth ( )
1267
- . withFlexibleHeight ( )
1269
+ . withFlexibleDimensions ( )
1270
+ . withPush ( false )
1268
1271
. withPositions ( [ {
1269
1272
overlayY : 'bottom' ,
1270
1273
overlayX : 'start' ,
@@ -1289,8 +1292,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1289
1292
originElement . style . left = '200px' ;
1290
1293
1291
1294
positionStrategy
1292
- . withFlexibleWidth ( )
1293
- . withFlexibleHeight ( )
1295
+ . withFlexibleDimensions ( )
1296
+ . withPush ( false )
1294
1297
. withPositions ( [ {
1295
1298
overlayY : 'top' ,
1296
1299
overlayX : 'start' ,
@@ -1315,8 +1318,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1315
1318
originElement . style . top = '200px' ;
1316
1319
1317
1320
positionStrategy
1318
- . withFlexibleWidth ( )
1319
- . withFlexibleHeight ( )
1321
+ . withFlexibleDimensions ( )
1322
+ . withPush ( false )
1320
1323
. withPositions ( [ {
1321
1324
overlayY : 'top' ,
1322
1325
overlayX : 'start' ,
@@ -1341,8 +1344,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1341
1344
originElement . style . top = '200px' ;
1342
1345
1343
1346
positionStrategy
1344
- . withFlexibleWidth ( )
1345
- . withFlexibleHeight ( )
1347
+ . withFlexibleDimensions ( )
1348
+ . withPush ( false )
1346
1349
. withPositions ( [ {
1347
1350
overlayY : 'top' ,
1348
1351
overlayX : 'end' ,
@@ -1368,7 +1371,7 @@ describe('FlexibleConnectedPositionStrategy', () => {
1368
1371
originElement . style . right = '200px' ;
1369
1372
1370
1373
positionStrategy
1371
- . withFlexibleHeight ( )
1374
+ . withFlexibleDimensions ( )
1372
1375
. withViewportMargin ( viewportMargin )
1373
1376
. withPositions ( [
1374
1377
{
@@ -1408,6 +1411,7 @@ describe('FlexibleConnectedPositionStrategy', () => {
1408
1411
// Create a strategy with knowledge of the scrollable container
1409
1412
const strategy = overlay . position ( )
1410
1413
. flexibleConnectedTo ( new ElementRef ( originElement ) )
1414
+ . withPush ( false )
1411
1415
. withPositions ( [ {
1412
1416
originX : 'start' ,
1413
1417
originY : 'bottom' ,
@@ -1503,8 +1507,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1503
1507
1504
1508
attachOverlay ( { positionStrategy} ) ;
1505
1509
1506
- expect ( overlayRef . overlayElement . style . left ) . toBeTruthy ( ) ;
1507
- expect ( overlayRef . overlayElement . style . right ) . toBeFalsy ( ) ;
1510
+ expect ( overlayRef . hostElement . style . left ) . toBeTruthy ( ) ;
1511
+ expect ( overlayRef . hostElement . style . right ) . toBeFalsy ( ) ;
1508
1512
} ) ;
1509
1513
1510
1514
it ( 'should use `right` when positioning an element at the end' , ( ) => {
@@ -1517,8 +1521,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1517
1521
1518
1522
attachOverlay ( { positionStrategy} ) ;
1519
1523
1520
- expect ( overlayRef . overlayElement . style . right ) . toBeTruthy ( ) ;
1521
- expect ( overlayRef . overlayElement . style . left ) . toBeFalsy ( ) ;
1524
+ expect ( overlayRef . hostElement . style . right ) . toBeTruthy ( ) ;
1525
+ expect ( overlayRef . hostElement . style . left ) . toBeFalsy ( ) ;
1522
1526
} ) ;
1523
1527
1524
1528
} ) ;
@@ -1537,8 +1541,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1537
1541
direction : 'rtl'
1538
1542
} ) ;
1539
1543
1540
- expect ( overlayRef . overlayElement . style . right ) . toBeTruthy ( ) ;
1541
- expect ( overlayRef . overlayElement . style . left ) . toBeFalsy ( ) ;
1544
+ expect ( overlayRef . hostElement . style . right ) . toBeTruthy ( ) ;
1545
+ expect ( overlayRef . hostElement . style . left ) . toBeFalsy ( ) ;
1542
1546
} ) ;
1543
1547
1544
1548
it ( 'should use `left` when positioning an element at the end' , ( ) => {
@@ -1551,8 +1555,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1551
1555
1552
1556
attachOverlay ( { positionStrategy, direction : 'rtl' } ) ;
1553
1557
1554
- expect ( overlayRef . overlayElement . style . left ) . toBeTruthy ( ) ;
1555
- expect ( overlayRef . overlayElement . style . right ) . toBeFalsy ( ) ;
1558
+ expect ( overlayRef . hostElement . style . left ) . toBeTruthy ( ) ;
1559
+ expect ( overlayRef . hostElement . style . right ) . toBeFalsy ( ) ;
1556
1560
} ) ;
1557
1561
} ) ;
1558
1562
@@ -1567,8 +1571,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1567
1571
1568
1572
attachOverlay ( { positionStrategy} ) ;
1569
1573
1570
- expect ( overlayRef . overlayElement . style . top ) . toBeTruthy ( ) ;
1571
- expect ( overlayRef . overlayElement . style . bottom ) . toBeFalsy ( ) ;
1574
+ expect ( overlayRef . hostElement . style . top ) . toBeTruthy ( ) ;
1575
+ expect ( overlayRef . hostElement . style . bottom ) . toBeFalsy ( ) ;
1572
1576
} ) ;
1573
1577
1574
1578
it ( 'should use `bottom` when positioning at element along the bottom' , ( ) => {
@@ -1581,8 +1585,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
1581
1585
1582
1586
attachOverlay ( { positionStrategy} ) ;
1583
1587
1584
- expect ( overlayRef . overlayElement . style . bottom ) . toBeTruthy ( ) ;
1585
- expect ( overlayRef . overlayElement . style . top ) . toBeFalsy ( ) ;
1588
+ expect ( overlayRef . hostElement . style . bottom ) . toBeTruthy ( ) ;
1589
+ expect ( overlayRef . hostElement . style . top ) . toBeFalsy ( ) ;
1586
1590
} ) ;
1587
1591
} ) ;
1588
1592
0 commit comments