Disable buttons if reached limits but not infinite

This commit is contained in:
Vadim
2021-01-23 17:14:17 +03:00
parent 56c3d2872f
commit 0e9afa20fa
2 changed files with 20 additions and 2 deletions

View File

@@ -4,10 +4,16 @@
* Indicates direction of the arrow ('next', 'prev') * Indicates direction of the arrow ('next', 'prev')
*/ */
export let direction = NEXT export let direction = NEXT
/**
* Indicates if button disabled
*/
export let disabled = false
</script> </script>
<div <div
class="circle" class="circle"
class:disabled
on:click on:click
> >
<i <i
@@ -49,4 +55,8 @@
transform: rotate(135deg); transform: rotate(135deg);
right: calc(var(--size) / -2); right: calc(var(--size) / -2);
} }
.disabled,
.disabled:hover {
opacity: 0.5;
}
</style> </style>

View File

@@ -173,7 +173,11 @@
{#if arrows} {#if arrows}
<slot name="prev" {showPrevPage}> <slot name="prev" {showPrevPage}>
<div class="arrow-container"> <div class="arrow-container">
<Arrow direction="prev" on:click={showPrevPage} /> <Arrow
direction="prev"
disabled={!infinite && originalCurrentPageIndex === 0}
on:click={showPrevPage}
/>
</div> </div>
</slot> </slot>
{/if} {/if}
@@ -199,7 +203,11 @@
{#if arrows} {#if arrows}
<slot name="next" {showNextPage}> <slot name="next" {showNextPage}>
<div class="arrow-container"> <div class="arrow-container">
<Arrow direction="next" on:click={showNextPage} /> <Arrow
direction="next"
disabled={!infinite && originalCurrentPageIndex === originalPagesCount - 1}
on:click={showNextPage}
/>
</div> </div>
</slot> </slot>
{/if} {/if}