Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loadStrategy() option #24

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/views/signature-pad.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$downloadActionDropdownPlacement = $getDownloadActionDropdownPlacement() ?? 'bottom-start';
$isUndoable = $isUndoable();
$isConfirmable = $isConfirmable();
$loadStrategy = $getLoadStrategy();

$clearAction = $getAction('clear');
$downloadAction = $getAction('download');
Expand All @@ -22,7 +23,7 @@
@endphp

<div
ax-load="visible"
ax-load="{{ $getLoadStrategy() }}"
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('filament-autograph', 'saade/filament-autograph') }}"
ax-load-css="{{ \Filament\Support\Facades\FilamentAsset::getStyleHref('filament-autograph-styles', 'saade/filament-autograph') }}"
x-data="signaturePad({
Expand Down
19 changes: 19 additions & 0 deletions src/Forms/Components/Concerns/HasOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ trait HasOptions

protected float | Closure $velocityFilterWeight = 0.7;

protected string | Closure $loadStrategy = 'visible';

/**
* Filename of the downloaded image. Without extension.
*/
Expand Down Expand Up @@ -167,6 +169,18 @@ public function velocityFilterWeight(float | Closure $velocityFilterWeight): sta
return $this;
}

/**
* Strategy used to load the signature pad.
* If you notice that the signature pad is not loading correctly in modals, consider changing this value to "idle".
* See https://async-alpine.dev/docs/strategies/ for more details.
*/
public function loadStrategy(string | Closure | null $loadStrategy): static
{
$this->loadStrategy = $loadStrategy;

return $this;
}

public function getDotSize(): float
{
return $this->evaluate($this->dotSize);
Expand Down Expand Up @@ -226,4 +240,9 @@ public function getVelocityFilterWeight(): float
{
return $this->evaluate($this->velocityFilterWeight);
}

public function getLoadStrategy(): string
{
return $this->evaluate($this->loadStrategy);
}
}