@@ -9,6 +9,7 @@ import { VideoParams, appendImageAsBackground, Logger } from '../util';
99 */
1010export class DDGVideoThumbnailOverlay extends HTMLElement {
1111 static CUSTOM_TAG_NAME = 'ddg-video-thumbnail-overlay-mobile' ;
12+ static OVERLAY_CLICKED = 'overlay-clicked' ;
1213
1314 policy = createPolicy ( ) ;
1415 /** @type {Logger } */
@@ -43,6 +44,14 @@ export class DDGVideoThumbnailOverlay extends HTMLElement {
4344 shadow . append ( style , container ) ;
4445 this . container = container ;
4546
47+ // Add click event listener to the overlay
48+ const overlay = container . querySelector ( '.ddg-video-player-overlay' ) ;
49+ if ( overlay ) {
50+ overlay . addEventListener ( 'click' , ( ) => {
51+ this . dispatchEvent ( new Event ( DDGVideoThumbnailOverlay . OVERLAY_CLICKED ) ) ;
52+ } ) ;
53+ }
54+
4655 this . logger ?. log ( 'Created' , DDGVideoThumbnailOverlay . CUSTOM_TAG_NAME , 'with container' , container ) ;
4756 this . appendThumbnail ( ) ;
4857 }
@@ -79,8 +88,9 @@ export class DDGVideoThumbnailOverlay extends HTMLElement {
7988 *
8089 * @param {HTMLElement } targetElement
8190 * @param {import('../environment').Environment } environment
91+ * @param {() => void } [onClick] Optional callback to be called when the overlay is clicked
8292 */
83- export function appendThumbnailOverlay ( targetElement , environment ) {
93+ export function appendThumbnailOverlay ( targetElement , environment , onClick ) {
8494 const logger = new Logger ( {
8595 id : 'THUMBNAIL_OVERLAY' ,
8696 shouldLog : ( ) => environment . isTestMode ( ) ,
@@ -93,6 +103,10 @@ export function appendThumbnailOverlay(targetElement, environment) {
93103 overlay . testMode = environment . isTestMode ( ) ;
94104 overlay . href = environment . getPlayerPageHref ( ) ;
95105
106+ if ( onClick ) {
107+ overlay . addEventListener ( DDGVideoThumbnailOverlay . OVERLAY_CLICKED , onClick ) ;
108+ }
109+
96110 targetElement . appendChild ( overlay ) ;
97111
98112 return ( ) => {
0 commit comments