Skip to content

Commit

Permalink
Remove setCurrentSlide api
Browse files Browse the repository at this point in the history
  • Loading branch information
nirav7707 committed Dec 2, 2024
1 parent 1ce3586 commit fbfa741
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
4 changes: 0 additions & 4 deletions src/lightbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,3 @@ Open the lightbox.
### `close`

Close the lightbox.

### `setCurrentSlide`

Set the current slide.
2 changes: 1 addition & 1 deletion src/lightbox/tp-lightbox-nav-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class TPLightboxNavItemElement extends HTMLElement {
}

// Set current slide.
this.lightbox.setCurrentSlide( this.getIndex() );
this.lightbox.currentIndex = Number( this.getIndex() ) ?? 1;

// Update navigation current item.
this.lightbox.updateNavCurrentItem();
Expand Down
30 changes: 7 additions & 23 deletions src/lightbox/tp-lightbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ export class TPLightboxElement extends HTMLElement {
index = 1;
}

// dispatch slide-set event.
this.dispatchEvent( new CustomEvent( 'slide-set', {
detail: {
slideIndex: index,
},
} ) );

// Setting this attributes triggers a re-trigger.
this.setAttribute( 'index', index.toString() );
}
Expand Down Expand Up @@ -491,29 +498,6 @@ export class TPLightboxElement extends HTMLElement {
}
}

/**
* Set the current slide index.
*
* @param {number} index Slide index.
*/
setCurrentSlide( index: number ): void {
// Check if slide index is valid.
if ( index > Number( this.getAttribute( 'total' ) ) || index <= 0 ) {
// Stop! It's not valid.
return;
}

// dispatch slide-set event.
this.dispatchEvent( new CustomEvent( 'slide-set', {
detail: {
slideIndex: index,
},
} ) );

// Set current slide index.
this.setAttribute( 'index', index.toString() );
}

/**
* Update current item in navigation.
*/
Expand Down

0 comments on commit fbfa741

Please sign in to comment.