Pagination
Preview
先頭ページ
中間ページ
末尾ページ
HTML
<tw-pagination page="1" total-pages="7"></tw-pagination>
<tw-pagination page="4" total-pages="7"></tw-pagination>
<tw-pagination page="7" total-pages="7"></tw-pagination>
import "@b4moss/the-wheels";
const bind = (pagerId, labelId) => {
const el = document.getElementById(pagerId);
const label = document.getElementById(labelId);
el?.addEventListener("tw-change", (event) => {
if (label) label.textContent = `page: ${event.detail.page}`;
});
};
bind("pager-first", "pagination-first-label");
bind("pager-middle", "pagination-middle-label");
bind("pager-last", "pagination-last-label");
import "@b4moss/the-wheels";
import type { TwPagination } from "@b4moss/the-wheels";
const bind = (pagerId: string, labelId: string) => {
const el = document.getElementById(pagerId) as TwPagination | null;
const label = document.getElementById(labelId);
el?.addEventListener("tw-change", ((event: CustomEvent<{ page: number }>) => {
if (label) label.textContent = `page: ${event.detail.page}`;
}) as EventListener);
};
bind("pager-first", "pagination-first-label");
bind("pager-middle", "pagination-middle-label");
bind("pager-last", "pagination-last-label");