2019-03-31 18:15:03 +03:00
|
|
|
function setCanvasOffset (canvas, offsetLeft, offsetTop) {
|
2019-03-27 02:20:54 +03:00
|
|
|
//horizontal offset
|
|
|
|
var minXOffset = -canvasSize[0]*zoom+ 164;
|
2019-03-31 19:41:08 +03:00
|
|
|
var maxXOffset = window.innerWidth - 148;
|
2019-03-27 02:20:54 +03:00
|
|
|
|
|
|
|
if (offsetLeft < minXOffset)
|
|
|
|
canvas.style.left = minXOffset +'px';
|
2019-03-31 18:15:03 +03:00
|
|
|
else if (offsetLeft > maxXOffset)
|
|
|
|
canvas.style.left = maxXOffset +'px';
|
2019-03-27 02:20:54 +03:00
|
|
|
else
|
2019-03-31 18:15:03 +03:00
|
|
|
canvas.style.left = offsetLeft +'px';
|
2019-03-27 02:20:54 +03:00
|
|
|
|
|
|
|
//vertical offset
|
|
|
|
var minYOffset = -canvasSize[1]*zoom + 164;
|
|
|
|
var maxYOffset = window.innerHeight-100;
|
|
|
|
|
|
|
|
if (offsetTop < minYOffset)
|
2019-03-31 18:15:03 +03:00
|
|
|
canvas.style.top = minYOffset +'px';
|
|
|
|
else if (offsetTop > maxYOffset)
|
|
|
|
canvas.style.top = maxYOffset +'px';
|
2019-03-27 02:20:54 +03:00
|
|
|
else
|
2019-03-31 18:15:03 +03:00
|
|
|
canvas.style.top = offsetTop +'px';
|
2019-03-27 02:20:54 +03:00
|
|
|
}
|