I've included fabric like so: <script src="js/fabric_freedrawing.js"></script>
But when I use it like this:
var canvas;
function initSketchPad() {
canvas = new fabric.Canvas('sketch-pad', {
isDrawingMode: true
});
}
I get
Uncaught TypeError: fabric.Canvas is not a constructor
I'm not sure what you have in your fabric_freedrawing.js
file but adding your code to a snippet below seems to work just fine.
var canvas;
function initSketchPad() {
canvas = new fabric.Canvas('sketch-pad', {
isDrawingMode: true
});
}
initSketchPad();
canvas {
border:1px solid;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.4/fabric.min.js"></script>
<canvas height=300 width=300 id="sketch-pad">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With