This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
466a16a
commit de62e65
Showing
7 changed files
with
69 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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,35 @@ | ||
export interface DeckdeckgoExtra { | ||
lazyLoadContent(): Promise<void>; | ||
} | ||
|
||
export class DeckdeckgoExtraUtils { | ||
|
||
static lazyLoadContent(el: HTMLElement, tag: string): Promise<void> { | ||
return new Promise<void>(async (resolve) => { | ||
const promises = []; | ||
|
||
const elements: HTMLElement[] = this.getAllElements(el, tag); | ||
|
||
if (elements && elements.length > 0) { | ||
|
||
elements.forEach((element: HTMLElement) => { | ||
promises.push((element as any).lazyLoadContent()); | ||
}); | ||
|
||
await Promise.all(promises); | ||
|
||
resolve(); | ||
} | ||
|
||
resolve(); | ||
}); | ||
} | ||
|
||
private static getAllElements(el: HTMLElement, tag: string): HTMLElement[] { | ||
const allSlottedElements: NodeListOf<HTMLElement> = el.querySelectorAll(tag); | ||
const allShadowsElements: NodeListOf<HTMLElement> = el.shadowRoot.querySelectorAll(tag); | ||
|
||
return Array.from(allSlottedElements).concat(Array.from(allShadowsElements)); | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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