From 5101bdf3ef642d664bc8328b43e5be73bf9bb545 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Wed, 17 Dec 2025 12:27:20 -0600 Subject: [PATCH] Added data attribute to allow auto playing slideshow and fixed mouseover event listeners --- js/components/dcf-slideshow.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/js/components/dcf-slideshow.js b/js/components/dcf-slideshow.js index 63c218b8..e6e56d85 100644 --- a/js/components/dcf-slideshow.js +++ b/js/components/dcf-slideshow.js @@ -218,10 +218,10 @@ width="24" height="24" viewBox="0 0 24 24" focusable="false" aria-hidden="true"> throw new Error(`Bad auto slide advance rate: ${this.slideshowContainer.dataset.rate}`); } } - this.slideDeck.addEventListener('mouseOver', () => { + this.slideshowContainer.addEventListener('mouseover', () => { this.mouseOver = true; }); - this.slideDeck.addEventListener('mouseOut', () => { + this.slideshowContainer.addEventListener('mouseout', () => { this.mouseOver = false; }); } @@ -243,6 +243,18 @@ width="24" height="24" viewBox="0 0 24 24" focusable="false" aria-hidden="true"> this.#initSlides(); this.#initControls(); + // This needs to go after init controls so we can change the state of the toggle button + if (this.allowPlay) { + if (!(window.matchMedia('(prefers-reduced-motion: reduce)').matches)) { + const startPlaying = this.slideshowContainer.hasAttribute('data-start-playing') && ( + this.slideshowContainer.dataset.startPlaying.toLowerCase() === 'true' + ); + if (startPlaying) { + this.play(); + } + } + } + this.slideshowContainer.classList.add('dcf-slideshow-initialized'); this.slideshowContainer.removeAttribute('hidden');