@@ -34,6 +34,12 @@ export const welcomePage: AdvantageFormat = {
3434 if ( ad ) {
3535 setDimensionsUntilAdvantageAdSlot ( ad ) ;
3636 }
37+ if ( config . closeButtonAnimationDuration !== undefined ) {
38+ wrapper . style . setProperty (
39+ "--adv-wp-transition-duration" ,
40+ `${ config . closeButtonAnimationDuration } s`
41+ ) ;
42+ }
3743
3844 // Change the content of the UI layer
3945 const uiContainer = document . createElement ( "div" ) ;
@@ -123,8 +129,11 @@ export const welcomePage: AdvantageFormat = {
123129 resetDimensionsUntilAdvantageAdSlot ( ad ) ;
124130 }
125131 wrapper . resetCSS ( ) ;
132+ wrapper . style . removeProperty ( "--adv-wp-transition-duration" ) ;
126133 } ,
127134 close : ( wrapper ) => {
135+ const container = wrapper . shadowRoot ?. getElementById ( "container" ) ;
136+
128137 function handleTransitionEnd ( ) {
129138 wrapper . style . display = "none" ;
130139 // Remove the event listener after it has been executed
@@ -134,8 +143,25 @@ export const welcomePage: AdvantageFormat = {
134143 ) ;
135144 }
136145
137- const container = wrapper . shadowRoot ?. getElementById ( "container" ) ;
138- container ?. addEventListener ( "transitionend" , handleTransitionEnd ) ;
146+ if ( container ) {
147+ const computedStyle = window . getComputedStyle ( container ) ;
148+ const transitionProperty = computedStyle . transitionProperty ;
149+ const transitionDuration = computedStyle . transitionDuration ;
150+
151+ const hasTransition =
152+ transitionProperty !== "none" &&
153+ transitionDuration . split ( "," ) . some ( ( d ) => parseFloat ( d ) > 0 ) ;
154+
155+ if ( ! hasTransition ) {
156+ wrapper . style . display = "none" ;
157+ wrapper . classList . remove ( "show" ) ;
158+ wrapper . style . height = "0px" ;
159+ return ;
160+ }
161+
162+ container . addEventListener ( "transitionend" , handleTransitionEnd ) ;
163+ }
164+
139165 wrapper . classList . remove ( "show" ) ;
140166 wrapper . style . height = "0px" ;
141167 }
0 commit comments