@@ -4,8 +4,18 @@ import { fromEvent, Subscription } from "rxjs";
44import { throttleTime } from "rxjs/operators" ;
55import position from "./../utils/position" ;
66
7+ const defaultOffset = { top : 0 , left : 0 } ;
8+
79@Injectable ( )
810export class DropdownService {
11+
12+ public set offset ( value : { top ?: number , left ?: number } ) {
13+ this . _offset = Object . assign ( { } , defaultOffset , value ) ;
14+ }
15+
16+ public get offset ( ) {
17+ return this . _offset ;
18+ }
919 /**
1020 * reference to the body appended menu
1121 */
@@ -17,6 +27,8 @@ export class DropdownService {
1727 */
1828 protected resize : Subscription ;
1929
30+ protected _offset = defaultOffset ;
31+
2032 constructor ( protected placeholderService : PlaceholderService ) { }
2133
2234 /**
@@ -84,8 +96,7 @@ export class DropdownService {
8496
8597 protected positionDropdown ( parentRef , menuRef ) {
8698 let pos = position . findAbsolute ( parentRef , menuRef , "bottom" ) ;
87- // add -40 to the top position to account for carbon styles
88- pos = position . addOffset ( pos , - 40 , 0 ) ;
99+ pos = position . addOffset ( pos , this . offset . top , this . offset . left ) ;
89100 position . setElement ( menuRef , pos ) ;
90101 }
91102}
0 commit comments