Merge pull request #15870 from marcusmoore/bug/sc-26857
Some checks failed
Crowdin Action / upload-sources-to-crowdin (push) Has been cancelled
Docker images (Alpine) / docker (push) Has been cancelled
Docker images / docker (push) Has been cancelled
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Has been cancelled
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Has been cancelled
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Has been cancelled
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Has been cancelled

Always call resizeCanvas
This commit is contained in:
snipe 2024-11-22 00:59:36 +00:00 committed by GitHub
commit f125c90c94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,10 +110,12 @@
canvas = wrapper.querySelector("canvas"),
signaturePad;
signaturePad = new SignaturePad(canvas);
// Adjust canvas coordinate space taking into account pixel ratio,
// to make it look crisp on mobile devices.
// This also causes canvas to be cleared.
if (window.matchMedia("(min-width: 768px)").matches) {
// to make it look crisp on smaller screens.
// https://github.com/szimek/signature_pad#handling-high-dpi-screens
// (This also causes canvas to be cleared.)
function resizeCanvas() {
// When zoomed out to less than 100%, for some very strange reason,
// some browsers report devicePixelRatio as less than 1
@ -122,12 +124,10 @@
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
window.onresize = resizeCanvas;
resizeCanvas();
}
signaturePad = new SignaturePad(canvas);
$('#clear_button').on("click", function (event) {
signaturePad.clear();