mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-03 18:07:41 -08:00
WIP: move signature pad creation up and add debugging
This commit is contained in:
parent
d0378070c8
commit
9f49c25401
|
@ -110,24 +110,28 @@
|
||||||
canvas = wrapper.querySelector("canvas"),
|
canvas = wrapper.querySelector("canvas"),
|
||||||
signaturePad;
|
signaturePad;
|
||||||
|
|
||||||
|
signaturePad = new SignaturePad(canvas);
|
||||||
|
|
||||||
// Adjust canvas coordinate space taking into account pixel ratio,
|
// Adjust canvas coordinate space taking into account pixel ratio,
|
||||||
// to make it look crisp on smaller screens.
|
// to make it look crisp on smaller screens.
|
||||||
// https://github.com/szimek/signature_pad#handling-high-dpi-screens
|
// https://github.com/szimek/signature_pad#handling-high-dpi-screens
|
||||||
// (This also causes canvas to be cleared.)
|
// (This also causes canvas to be cleared.)
|
||||||
function resizeCanvas() {
|
function resizeCanvas() {
|
||||||
|
console.log('resizeCanvas');
|
||||||
// When zoomed out to less than 100%, for some very strange reason,
|
// When zoomed out to less than 100%, for some very strange reason,
|
||||||
// some browsers report devicePixelRatio as less than 1
|
// some browsers report devicePixelRatio as less than 1
|
||||||
// and only part of the canvas is cleared then.
|
// and only part of the canvas is cleared then.
|
||||||
var ratio = Math.max(window.devicePixelRatio || 1, 1);
|
let devicePixelRatio = window.devicePixelRatio;
|
||||||
|
console.log({devicePixelRatio})
|
||||||
|
var ratio = Math.max(devicePixelRatio || 1, 1);
|
||||||
canvas.width = canvas.offsetWidth * ratio;
|
canvas.width = canvas.offsetWidth * ratio;
|
||||||
canvas.height = canvas.offsetHeight * ratio;
|
canvas.height = canvas.offsetHeight * ratio;
|
||||||
canvas.getContext("2d").scale(ratio, ratio);
|
canvas.getContext("2d").scale(ratio, ratio);
|
||||||
|
signaturePad.clear(); // otherwise isEmpty() might return incorrect value
|
||||||
}
|
}
|
||||||
window.onresize = resizeCanvas;
|
window.onresize = resizeCanvas;
|
||||||
resizeCanvas();
|
resizeCanvas();
|
||||||
|
|
||||||
signaturePad = new SignaturePad(canvas);
|
|
||||||
|
|
||||||
$('#clear_button').on("click", function (event) {
|
$('#clear_button').on("click", function (event) {
|
||||||
signaturePad.clear();
|
signaturePad.clear();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue