mirror of
https://github.com/JeremyLikness/vanillajs-deck
synced 2024-11-14 17:44:56 +00:00
Extend navigation to support "appears"
This commit is contained in:
parent
47a3dc8ba5
commit
274dc9077b
2
js/controls.js
vendored
2
js/controls.js
vendored
@ -93,7 +93,7 @@ export class Controls extends HTMLElement {
|
|||||||
this._controlRef.first.disabled = !prev;
|
this._controlRef.first.disabled = !prev;
|
||||||
this._controlRef.prev.disabled = !prev;
|
this._controlRef.prev.disabled = !prev;
|
||||||
this._controlRef.next.disabled = !next;
|
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}`;
|
this._controlRef.pos.innerText = `${this._deck.currentIndex + 1} / ${this._deck.totalSlides}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,11 @@ export class Navigator extends HTMLElement {
|
|||||||
* @returns {boolean} True if a subsequent slide exists
|
* @returns {boolean} True if a subsequent slide exists
|
||||||
*/
|
*/
|
||||||
get hasNext() {
|
get hasNext() {
|
||||||
|
const host = this.querySelector("div");
|
||||||
|
const appear = host.querySelectorAll(".appear");
|
||||||
|
if (appear && appear.length) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return this._currentIndex < (this.totalSlides - 1);
|
return this._currentIndex < (this.totalSlides - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +165,7 @@ export class Navigator extends HTMLElement {
|
|||||||
*/
|
*/
|
||||||
next() {
|
next() {
|
||||||
if (this.checkForAppears()) {
|
if (this.checkForAppears()) {
|
||||||
|
this.dispatchEvent(this.slidesChangedEvent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.hasNext) {
|
if (this.hasNext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user