Skip to content

Commit

Permalink
Refactor function call and remove bubble from custom event
Browse files Browse the repository at this point in the history
  • Loading branch information
nirav7707 committed Nov 29, 2024
1 parent fe928ab commit 5b33675
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/lightbox/tp-lightbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export class TPLightboxElement extends HTMLElement {
if ( 'index' === name ) {
this.triggerCurrentIndexTarget();
}

// Trigger navigation update if open or index has changed.
if ( 'open' === name || 'index' === name) {

Check failure on line 77 in src/lightbox/tp-lightbox.ts

View workflow job for this annotation

GitHub Actions / test

There must be a space before this paren
this.updateNavCurrentItem();
}
}

/**
Expand Down Expand Up @@ -202,9 +207,6 @@ export class TPLightboxElement extends HTMLElement {
// Now, show the modal.
dialog.showModal();
this.setAttribute( 'open', 'yes' );

// Update navigation current item.
this.updateNavCurrentItem();
}

/**
Expand Down Expand Up @@ -243,9 +245,6 @@ export class TPLightboxElement extends HTMLElement {
if ( this.currentIndex > 1 ) {
this.currentIndex--;
}

// Update navigation current item.
this.updateNavCurrentItem();
}

/**
Expand All @@ -271,9 +270,6 @@ export class TPLightboxElement extends HTMLElement {
if ( this.currentIndex < allGroups.length ) {
this.currentIndex++;
}

// Update navigation current item.
this.updateNavCurrentItem();
}

/**
Expand Down Expand Up @@ -509,7 +505,6 @@ export class TPLightboxElement extends HTMLElement {

// dispatch slide-set event.
this.dispatchEvent( new CustomEvent( 'slide-set', {
bubbles: true,
detail: {
slideIndex: index,
},
Expand Down

0 comments on commit 5b33675

Please sign in to comment.