Skip to content

Commit

Permalink
Use slotted control panel
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Jan 4, 2024
1 parent bdfcc3a commit 5958c3a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions slide-deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,14 @@ class slideDeck extends HTMLElement {

// relevant nodes
this.body = document.querySelector('body');
this.controlPanel = this.shadowRoot.querySelector(`[part="control-panel"]`);
this.controlPanel = this.querySelector(`[slot="control-panel"]`) ??
this.shadowRoot.querySelector(`[part="control-panel"]`);

// initial setup
this.slideCount = this.childElementCount;
const slides = this.querySelectorAll(':scope > :not([slot])');
this.slideCount = slides.length;
this.defaultAttrs();
this.setSlideIDs();
this.setSlideIDs(slides);
this.goTo();

// buttons
Expand Down Expand Up @@ -210,9 +212,7 @@ class slideDeck extends HTMLElement {

slideId = (n) => `slide_${this.id}-${n}`;

setSlideIDs = () => {
const slides = this.querySelectorAll(':scope > :not([slot=controls])');

setSlideIDs = (slides) => {
slides.forEach((slide, index) => {
slide.id = this.slideId(index + 1);
});
Expand Down

0 comments on commit 5958c3a

Please sign in to comment.