mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
13cc6fe3b2
Signed-off-by: npalomba <nicola.palomba@studenti.galileilivorno.gov.it>
23 lines
724 B
JavaScript
23 lines
724 B
JavaScript
function setCanvasOffset (canvas, offsetLeft, offsetTop) {
|
|
//horizontal offset
|
|
var minXOffset = -canvasSize[0]*zoom+ 164;
|
|
var maxXOffset = window.innerWidth - 148;
|
|
|
|
if (offsetLeft < minXOffset)
|
|
canvas.style.left = minXOffset +'px';
|
|
else if (offsetLeft > maxXOffset)
|
|
canvas.style.left = maxXOffset +'px';
|
|
else
|
|
canvas.style.left = offsetLeft +'px';
|
|
|
|
//vertical offset
|
|
var minYOffset = -canvasSize[1]*zoom + 164;
|
|
var maxYOffset = window.innerHeight-100;
|
|
|
|
if (offsetTop < minYOffset)
|
|
canvas.style.top = minYOffset +'px';
|
|
else if (offsetTop > maxYOffset)
|
|
canvas.style.top = maxYOffset +'px';
|
|
else
|
|
canvas.style.top = offsetTop +'px';
|
|
} |