@@ -4,8 +4,17 @@ 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+ public set offset ( value : { top ?: number , left ?: number } ) {
12+ this . _offset = Object . assign ( { } , defaultOffset , value ) ;
13+ }
14+
15+ public get offset ( ) {
16+ return this . _offset ;
17+ }
918 /**
1019 * reference to the body appended menu
1120 */
@@ -17,6 +26,8 @@ export class DropdownService {
1726 */
1827 protected resize : Subscription ;
1928
29+ protected _offset = defaultOffset ;
30+
2031 constructor ( protected placeholderService : PlaceholderService ) { }
2132
2233 /**
@@ -84,8 +95,7 @@ export class DropdownService {
8495
8596 protected positionDropdown ( parentRef , menuRef ) {
8697 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 ) ;
98+ pos = position . addOffset ( pos , this . offset . top , this . offset . left ) ;
8999 position . setElement ( menuRef , pos ) ;
90100 }
91101}
0 commit comments