Skip to content

Commit

Permalink
Merge pull request #66 from ACT-Training/65-prevent-scroll-on-pagination
Browse files Browse the repository at this point in the history
✨ add scroll option
SimonBarrettACT authored Aug 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents b3fa4c4 + 3f9d592 commit 79e05a8
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/views/report.blade.php
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ class="sr-only ml-2 text-sm font-medium text-gray-900 dark:text-gray-300"></labe

@if($this->isPaginated() && $this->rows->hasPages())
<div class="border-b border-gray-200 shadow-sm">
<div class="py-2 px-6">{{ $this->rows->links() }}</div>
<div class="py-2 px-6">{{ $this->rows->links(['scrollTo' => $this->shouldScroll()]) }}</div>
</div>
@endif
@endif
2 changes: 1 addition & 1 deletion resources/views/table.blade.php
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@
<div>
@if($this->isPaginated() && $this->rows->hasPages())
<div class="border-b border-gray-200 shadow-sm">
<div class="py-2 px-6">{{ $this->rows->links() }}</div>
<div class="py-2 px-6">{{ $this->rows->links(['scrollTo' => $this->shouldScroll()]) }}</div>
</div>
@endif
</div>
14 changes: 14 additions & 0 deletions src/Support/Concerns/WithPagination.php
Original file line number Diff line number Diff line change
@@ -12,13 +12,27 @@ trait WithPagination

private bool $paginate = true;

private bool $scrollToTop = false;

public function usePagination($usePagination = true): static
{
$this->paginate = $usePagination;

return $this;
}

public function scrollToTop($scrollToTop = true): static
{
$this->scrollToTop = $scrollToTop;

return $this;
}

public function shouldScroll(): bool
{
return $this->scrollToTop;
}

public function pageName($pageName = null): static
{
$this->pageName = $pageName;

0 comments on commit 79e05a8

Please sign in to comment.