File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,18 @@ export const createPanel = (
6161 if ( item . toolTip ) {
6262 const menuTooltip = document . createElement ( 'menu-item-tooltip' ) ;
6363 menuTooltip . append ( item . toolTip ) ;
64- menu . append ( menuTooltip ) ;
64+
65+ menu . addEventListener ( 'mouseenter' , ( ) => {
66+ const rect = menu . getBoundingClientRect ( ) ;
67+ menuTooltip . style . setProperty ( 'max-width' , `${ rect . width - 8 } px` ) ;
68+ menuTooltip . style . setProperty ( '--x' , `${ rect . left } px` ) ;
69+ menuTooltip . style . setProperty ( '--y' , `${ rect . top + rect . height } px` ) ;
70+ menuTooltip . classList . add ( 'show' ) ;
71+ } ) ;
72+ menu . addEventListener ( 'mouseleave' , ( ) => {
73+ menuTooltip . classList . remove ( 'show' ) ;
74+ } ) ;
75+ parent . append ( menuTooltip ) ;
6576 }
6677
6778 menu . addEventListener ( 'click' , async ( ) => {
Original file line number Diff line number Diff line change @@ -152,10 +152,10 @@ menu-item-badge {
152152}
153153
154154menu-item-tooltip {
155- position : absolute ;
155+ position : fixed ;
156156
157- left : 0 ;
158- top : calc ( 100 % + 4 px );
157+ left : var ( --x , 0 ) ;
158+ top : var ( --y , 0 );
159159
160160 display : flex;
161161 justify-content : center;
@@ -176,9 +176,9 @@ menu-item-tooltip {
176176 scale : 0.9 ;
177177
178178 transform-origin : 50% 0 ;
179- transition : all 0.225s ease-out;
179+ transition : opacity 0.225 s ease-out , scale 0.225s ease-out;
180180}
181- menu-item : hover > menu-item- tooltip {
181+ menu-item- tooltip . show {
182182 opacity : 1 ;
183183 scale : 1.0 ;
184184}
You can’t perform that action at this time.
0 commit comments