UNPKG

@djs-button-pages/presets

Version:

A set of presets that are used for faster development.

42 lines (41 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const djs_button_pages_1 = require("djs-button-pages"); /** * Bind for button that switches pagination to the next page. */ class NextPageButton extends djs_button_pages_1.ButtonWrapper { /** * Bind for button that switches pagination to the next page. * @param {ButtonData} style Styling for button. */ constructor(style) { super(style); this.setAction(NextPageButton._doAction); this.setSwitch(NextPageButton._switch); } ; /** * Action that switches pagination to the next page. * @param {PaginationSent} pagination Pagination. * @returns {Promise<void>} */ static async _doAction(pagination) { pagination.setPage(pagination.page + 1); return pagination.update(); } ; /** * Switch that disables button on the last page. * @param {PaginationSent} pagination Pagination. * @returns {boolean} */ static _switch(pagination) { if (pagination.page === pagination.data.embeds.length - 1) return true; return false; } ; } exports.default = NextPageButton; ;