File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 1
1
import tippy from 'tippy.js' ;
2
2
3
+ const visibleInstances = new Set ( ) ;
4
+
3
5
export function createTippy ( target , opts = { } ) {
4
6
const instance = tippy ( target , {
5
7
appendTo : document . body ,
@@ -9,6 +11,14 @@ export function createTippy(target, opts = {}) {
9
11
interactiveBorder : 20 ,
10
12
ignoreAttributes : true ,
11
13
maxWidth : 500 , // increase over default 350px
14
+ onHide : ( instance ) => visibleInstances . delete ( instance ) ,
15
+ onDestroy : ( instance ) => visibleInstances . delete ( instance ) ,
16
+ onShow : ( instance ) => {
17
+ for ( const visibleInstance of visibleInstances ) {
18
+ visibleInstance . hide ( ) ; // hide other instances
19
+ }
20
+ visibleInstances . add ( instance ) ;
21
+ } ,
12
22
arrow : `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>` ,
13
23
...( opts ?. role && { theme : opts . role } ) ,
14
24
...opts ,
You can’t perform that action at this time.
0 commit comments