From 274dc9077be88d7d1135fd076fbf07eed6c472ed Mon Sep 17 00:00:00 2001 From: Jeremy Likness Date: Tue, 26 Nov 2019 09:51:45 -0800 Subject: [PATCH] Extend navigation to support "appears" --- js/controls.js | 2 +- js/navigator.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/controls.js b/js/controls.js index 64ff9cb..e4f7304 100644 --- a/js/controls.js +++ b/js/controls.js @@ -93,7 +93,7 @@ export class Controls extends HTMLElement { this._controlRef.first.disabled = !prev; this._controlRef.prev.disabled = !prev; this._controlRef.next.disabled = !next; - this._controlRef.last.disabled = !next; + this._controlRef.last.disabled = this._deck.currentIndex === (this._deck.totalSlides - 1); this._controlRef.pos.innerText = `${this._deck.currentIndex + 1} / ${this._deck.totalSlides}`; } } diff --git a/js/navigator.js b/js/navigator.js index d6fb3fe..27a4772 100644 --- a/js/navigator.js +++ b/js/navigator.js @@ -116,6 +116,11 @@ export class Navigator extends HTMLElement { * @returns {boolean} True if a subsequent slide exists */ get hasNext() { + const host = this.querySelector("div"); + const appear = host.querySelectorAll(".appear"); + if (appear && appear.length) { + return true; + } return this._currentIndex < (this.totalSlides - 1); } @@ -160,6 +165,7 @@ export class Navigator extends HTMLElement { */ next() { if (this.checkForAppears()) { + this.dispatchEvent(this.slidesChangedEvent); return; } if (this.hasNext) {