@@ -26,12 +26,12 @@ export class Panel {
26
26
}
27
27
28
28
open ( { content, className, highlight, actions = [ ] } = { } ) {
29
+ let isOpen = false
29
30
if ( this . isOpen ( ) ) {
31
+ isOpen = true
30
32
this . onClose ( )
31
33
}
32
- this . container . className = `with-transition panel window ${ this . className } ${
33
- this . mode || ''
34
- } `
34
+ this . container . className = `with-transition panel window ${ this . className } ${ this . mode || '' } ${ isOpen ? 'on' : '' } `
35
35
if ( highlight ) {
36
36
this . container . dataset . highlight = highlight
37
37
}
@@ -56,8 +56,18 @@ export class Panel {
56
56
}
57
57
if ( className ) DomUtil . addClass ( body , className )
58
58
const promise = new Promise ( ( resolve , reject ) => {
59
- DomUtil . addClass ( this . container , 'on' )
60
- resolve ( this )
59
+ if ( isOpen ) {
60
+ resolve ( this )
61
+ } else {
62
+ this . container . addEventListener (
63
+ 'transitionend' ,
64
+ ( ) => {
65
+ resolve ( this )
66
+ } ,
67
+ { once : true }
68
+ )
69
+ this . container . classList . add ( 'on' )
70
+ }
61
71
} )
62
72
DomEvent . on ( closeButton , 'click' , this . close , this )
63
73
DomEvent . on ( resizeButton , 'click' , this . resize , this )
@@ -83,8 +93,8 @@ export class Panel {
83
93
}
84
94
85
95
onClose ( ) {
86
- if ( DomUtil . hasClass ( this . container , 'on' ) ) {
87
- DomUtil . removeClass ( this . container , 'on' )
96
+ if ( this . container . classList . contains ( 'on' ) ) {
97
+ this . container . classList . remove ( 'on' )
88
98
this . _leafletMap . invalidateSize ( { pan : false } )
89
99
}
90
100
}
0 commit comments