import Flickity from 'flickity'; (() => { const { PrevNextButton } = Flickity; const parentUpdate = PrevNextButton.prototype.update; PrevNextButton.prototype.update = function update() { parentUpdate.call(this); if (this.parent.slideableWidth < this.parent.size.innerWidth) { this.disable(); // this.element.classList.add('hide'); } else if (this.element.classList.contains('hide')) { // this.element.classList.remove('hide'); } // disable next button of "last page" if (this.parent.options.contain) { const { cells } = this.parent; let isEnabling = true; const selectedCell = cells[this.parent.selectedIndex]; if (!this.isPrevious) { isEnabling = selectedCell.target + this.parent.size.width < this.parent.slideableWidth; const method = isEnabling ? 'enable' : 'disable'; this[method](); } } }; })();