Reputation: 526
How can I use 1 canvas into multiple types of JavaScript? Like below I want to access my canvas by getElementByid and fabric.canvas as well because some of my functions are written in fabricjs others are not and merging them is getting impossible is there a way ?
<canvas id="canvas" width="300" height="300" style="border: 1px solid black;"></canvas>
canvas = document.getElementById("canvas");
canvas1 = new fabric.Canvas("canvas");
ctx = canvas.getContext("2d");
Upvotes: 0
Views: 53
Reputation:
It's possible but this sounds as a bad idea as it will most likely interfere with internal book-keeping in the library.
If you change something and the library isn't aware of it you will loose the changes next time the library updates.
As markE mentions in the comments, some library (incl. Fabric's createClass
) allow you to extend their basic functionality. This is the recommended path. That or no library.
Upvotes: 1