-
Notifications
You must be signed in to change notification settings - Fork 1
Add Lightbox nav items #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
209aee2
Add navitem subcomponent
nirav7707 7edd07c
Update readme file
nirav7707 fe928ab
Fix lint errors
nirav7707 5b33675
Refactor function call and remove bubble from custom event
nirav7707 1ce3586
Add space before paren
nirav7707 fbfa741
Remove setCurrentSlide api
nirav7707 5896727
Refactor code and update readme
nirav7707 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /** | ||
| * Internal dependencies. | ||
| */ | ||
| import { TPLightboxElement } from './tp-lightbox'; | ||
| import { TPLightboxNavElement } from './tp-lightbox-nav'; | ||
|
|
||
| /** | ||
| * TP Lightbox Nav Item. | ||
| */ | ||
| export class TPLightboxNavItemElement extends HTMLElement { | ||
| /** | ||
| * Properties. | ||
| */ | ||
| protected lightbox : TPLightboxElement | null; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| */ | ||
| constructor() { | ||
| // Initialize parent. | ||
| super(); | ||
| this.lightbox = this.closest( 'tp-lightbox' ); | ||
|
|
||
| // Get the nav-item button. | ||
| this.querySelector( 'button' )?.addEventListener( 'click', this.handleClick.bind( this ) ); | ||
| } | ||
|
|
||
| /** | ||
| * Handle when the button is clicked. | ||
| */ | ||
| handleClick(): void { | ||
| // Check if lightbox exists. | ||
| if ( ! this.lightbox ) { | ||
| // No its not! Terminate. | ||
| return; | ||
| } | ||
|
|
||
| // Set current slide. | ||
| this.lightbox.currentIndex = Number( this.getIndex() ) ?? 1; | ||
|
|
||
| // Update navigation current item. | ||
| this.lightbox.updateNavCurrentItem(); | ||
| } | ||
|
|
||
| /** | ||
| * Get index of this item inside the navigation. | ||
| * | ||
| * @return {number} Index. | ||
| */ | ||
| getIndex(): number { | ||
| // Bail if no lightbox. | ||
| if ( ! this.lightbox ) { | ||
| // Exit. | ||
| return 0; | ||
| } | ||
|
|
||
| // No, find it in the navigation. | ||
| const lightboxNav: TPLightboxNavElement | null = this.closest( 'tp-lightbox-nav' ); | ||
|
|
||
| // Return index of this element considering the step value. | ||
| return ( Array.from( lightboxNav?.children ?? [] ).indexOf( this ) ) + 1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /** | ||
| * TP Lightbox Nav. | ||
| */ | ||
| export class TPLightboxNavElement extends HTMLElement { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.