I'm having an issue using the npm module - signature_pad, and can't seem to get it set up. At the moment all I am using is vanilla HTML, CSS and JS. At the moment I keep getting an error saying: SignaturePad is not defined
. I tried importing the module from my package.JSON file using import SignaturePad from 'signature_pad'
but I get an error back saying unexpected token import
.
I have attached my HTML and JS code below. Any suggestions?
JavaScript
var wrapper1 = document.getElementById("signature-pad-1"),
canvas1 = wrapper1.querySelector("canvas"),
signaturePad1;
resizeCanvas(canvas1);
signaturePad1 = new SignaturePad(canvas1);
function resizeCanvas(canvas) {
var ratio = window.devicePixelRatio || 1;
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
}
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sign Here</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="contract">
<h1>Signature Below</h1>
<p>ABC</p>
<div id="signature-pad-1" class="m-signature-pad">
<div class="m-signature-pad--body">
<canvas></canvas>
</div>
</div>
<script type="text/javascript" src="./js/sig_pad.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/signature_pad/1.5.3/signature_pad.min.js"></script>
</body>
</html>
via Todd Drinkwater
No comments:
Post a Comment