@@ -29,7 +29,6 @@ export class DDGVideoDrawerMobile extends HTMLElement {
2929 /** @type {HTMLElement | null } */
3030 drawer ;
3131
32-
3332 connectedCallback ( ) {
3433 this . createMarkupAndStyles ( ) ;
3534 }
@@ -44,10 +43,7 @@ export class DDGVideoDrawerMobile extends HTMLElement {
4443 shadow . append ( style , overlayElement ) ;
4544 this . setupElements ( overlayElement ) ;
4645 this . setupEventHandlers ( ) ;
47-
48- // setTimeout(() => {
49- this . animate ( 'in' ) ;
50- // }, 100); /* TODO FIX THIS */
46+ this . animateOverlay ( 'in' ) ;
5147 }
5248
5349 /** @param {HTMLElement } container */
@@ -102,11 +98,11 @@ export class DDGVideoDrawerMobile extends HTMLElement {
10298 *
10399 * @param {'in'|'out' } direction
104100 */
105- animate ( direction ) {
101+ animateOverlay ( direction ) {
106102 const overlay = this . container ?. querySelector ( '.ddg-mobile-drawer-overlay' ) ;
107103 if ( ! overlay ) return ;
108104
109- switch ( direction ) {
105+ switch ( direction ) {
110106 case 'in' :
111107 overlay . classList . remove ( 'animateOut' ) ;
112108 overlay . classList . add ( 'animateIn' ) ;
@@ -132,7 +128,15 @@ export class DDGVideoDrawerMobile extends HTMLElement {
132128 const overlay = this . container . querySelector ( '.ddg-mobile-drawer-overlay' ) ;
133129 const background = this . container . querySelector ( '.ddg-mobile-drawer-background' ) ;
134130
135- if ( ! cancelElement || ! watchInPlayer || ! switchElem || ! infoButton || ! overlay || ! background || ! ( remember instanceof HTMLInputElement ) ) {
131+ if (
132+ ! cancelElement ||
133+ ! watchInPlayer ||
134+ ! switchElem ||
135+ ! infoButton ||
136+ ! overlay ||
137+ ! background ||
138+ ! ( remember instanceof HTMLInputElement )
139+ ) {
136140 return console . warn ( 'missing elements' ) ;
137141 }
138142
@@ -151,28 +155,20 @@ export class DDGVideoDrawerMobile extends HTMLElement {
151155 }
152156 } ) ;
153157
154- const cancelHandler = ( e ) => {
155- if ( ! e . isTrusted ) return ;
156- e . preventDefault ( ) ;
157- e . stopImmediatePropagation ( ) ;
158- this . animate ( 'out' ) ;
159- this . dispatchEvent ( new CustomEvent ( DDGVideoDrawerMobile . OPT_OUT , { detail : { remember : remember . checked } } ) ) ;
160- } ;
161-
162158 cancelElement . addEventListener ( 'click' , ( e ) => {
163159 if ( ! e . isTrusted ) return ;
164160 e . preventDefault ( ) ;
165161 e . stopImmediatePropagation ( ) ;
166- this . animate ( 'out' ) ;
162+ this . animateOverlay ( 'out' ) ;
167163 this . dispatchEvent ( new CustomEvent ( DDGVideoDrawerMobile . OPT_OUT , { detail : { remember : remember . checked } } ) ) ;
168164 } ) ;
169165
170166 background . addEventListener ( 'click' , ( e ) => {
171167 if ( ! e . isTrusted || e . target !== background ) return ;
172168 e . preventDefault ( ) ;
173169 e . stopImmediatePropagation ( ) ;
174- this . animate ( 'out' ) ;
175- this . dispatchEvent ( new CustomEvent ( DDGVideoDrawerMobile . DISMISS , { detail : { remember : false } } ) ) ;
170+ this . animateOverlay ( 'out' ) ;
171+ this . dispatchEvent ( new CustomEvent ( DDGVideoDrawerMobile . DISMISS ) ) ;
176172 } ) ;
177173
178174 watchInPlayer . addEventListener ( 'click' , ( e ) => {
0 commit comments