File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 2121 border : 1px solid color-mix (in srgb, var (--mat-sys-outline ) 40% , transparent);
2222}
2323
24+ .example-menu [popover ] {
25+ position : absolute;
26+ }
27+
2428.example-menu-bar {
2529 display : flex;
2630 cursor : pointer;
Original file line number Diff line number Diff line change @@ -29,15 +29,21 @@ export class SimpleMenu {
2929 const parentEl = parent . element ;
3030 const parentRect = parentEl . getBoundingClientRect ( ) ;
3131
32+ const scrollX = window . scrollX ;
33+ const scrollY = window . scrollY ;
34+
35+ const top = parentRect . y + scrollY - 5 ;
36+ const bottom = parentRect . y + scrollY + parentRect . height + 6 ;
37+
3238 if ( parent . parent instanceof MenuBar ) {
33- this . menu . element . style . left = `${ parentRect . left } px` ;
34- this . menu . element . style . top = `${ parentRect . bottom + 6 } px` ;
39+ this . menu . element . style . left = `${ parentRect . left + scrollX } px` ;
40+ this . menu . element . style . top = `${ bottom } px` ;
3541 } else if ( parent instanceof MenuTrigger ) {
36- this . menu . element . style . left = `${ parentRect . left } px` ;
37- this . menu . element . style . top = `${ parentRect . bottom + 2 } px` ;
42+ this . menu . element . style . left = `${ parentRect . left + scrollX } px` ;
43+ this . menu . element . style . top = `${ parentRect . bottom + scrollY + 2 } px` ;
3844 } else {
39- this . menu . element . style . left = `${ parentRect . right + 6 } px` ;
40- this . menu . element . style . top = `${ parentRect . top - 5 } px` ;
45+ this . menu . element . style . left = `${ parentRect . right + scrollX + 6 } px` ;
46+ this . menu . element . style . top = `${ top } px` ;
4147 }
4248 }
4349}
You can’t perform that action at this time.
0 commit comments