Extend navigation to support "appears"

This commit is contained in:
Jeremy Likness 2019-11-26 09:51:45 -08:00
parent 47a3dc8ba5
commit 274dc9077b
2 changed files with 7 additions and 1 deletions

2
js/controls.js vendored
View File

@ -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}`;
}
}

View File

@ -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) {