File tree 1 file changed +14
-0
lines changed
1 file changed +14
-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,18 @@ export function createTippy(target, opts = {}) {
9
11
interactiveBorder : 20 ,
10
12
ignoreAttributes : true ,
11
13
maxWidth : 500 , // increase over default 350px
14
+ onHide : ( instance ) => {
15
+ visibleInstances . delete ( instance ) ;
16
+ } ,
17
+ onDestroy : ( instance ) => {
18
+ visibleInstances . delete ( instance ) ;
19
+ } ,
20
+ onShow : ( instance ) => {
21
+ for ( const visibleInstance of visibleInstances ) {
22
+ visibleInstance . hide ( ) ; // hide other instances
23
+ }
24
+ visibleInstances . add ( instance ) ;
25
+ } ,
12
26
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
27
...( opts ?. role && { theme : opts . role } ) ,
14
28
...opts ,
You can’t perform that action at this time.
0 commit comments