My code contains a div that is 85% of the view-port and it holds a canvas. I have currently made the canvas scroll-able on-click but for some reason anytime I call canvas.style.transform = "scale(2,2)"; the canvas remains the same size. Any help?
EDIT - i was making the call to scale in the scaleUp() function
<!--Div to view, div to zoom, div to translate -->
<div id="view-translate" style="height:85vh; background-color:#f2f2f2; overflow:hidden; ">
<canvas id="ctx" height="4000" width="4000" oncontextmenu="return false;" style="background-color:#ffffff;"></canvas>
</div>
<p id="text"></p>
<button onclick="scaleUp()">yes</button>
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script>
//NETWORK VARIABLES
var socket = io();
//GETTING HTML ITEMS BY ID
var tran = document.getElementById("view-translate");
var canvas = document.getElementById("ctx");
ctx = canvas.getContext("2d");
//canvas.style.transform = "scale(2,2)";
//canvas.style.transform = "translate(0px,0px)";
var tx = 0,//release x and y
ty = 0,
cx = 0,//click x and y
cy = 0,
mx= 0,//move x and y
my = 0,
scale = 1,
draggable = false;
ctx.fillStyle="red";
ctx.fillRect(0,0,4,4);
function scaleUp(){
}
//GETTING THE MOUSE X AND Y
function getMousePos(canvas, event){
var rect = canvas.getBoundingClientRect();
return {
x:event.clientX - rect.left,
y:event.clientY - rect.top
};
}
canvas.addEventListener('mousedown', function(event){
var pos = getMousePos(canvas, event);
cx = pos.x;
cy = pos.y;
if(event.which === 3){
draggable = true;
}
if(event.which === 1){
alert(cx + " " + cy);
}
if(event.which === 2){
}
}, false );
tran.addEventListener('mousedown', function(event){
var pos = getMousePos(tran, event);
if(event.which === 3){
}
if(event.which === 1){
}
if(event.which === 2){
}
}, false );
tran.addEventListener('mouseup', function(event){
if(event.which === 3){
draggable = false;
}
if(event.which === 1){
}
if(event.which === 2){
}
}, false );
tran.addEventListener('mousemove', function(event){
var pos = getMousePos(tran, event);
mx = pos.x;
my = pos.y;
document.getElementById("text").innerHTML = mx + ", " + my + " size:" + canvas.height + " " + canvas.width;
if(draggable){
tx = mx - cx;
ty = my - cy;
document.getElementById("text").innerHTML = "CLICK!" + tx + ", " + ty;
canvas.style.transform = "translate(" + tx + "px, " + ty + "px)";
}
}, false);
</script>
</html>