2018-06-24 10:02:09 +02:00
|
|
|
window.addEventListener("keydown", function(e) {
|
|
|
|
// space and arrow keys
|
2019-10-14 20:00:42 +02:00
|
|
|
if ([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
|
2018-06-24 10:02:09 +02:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
}, false);
|
2019-10-14 20:00:42 +02:00
|
|
|
let xvb = 0;
|
|
|
|
let yvb = 0;
|
|
|
|
let zoomx = window.innerWidth;
|
|
|
|
let zoomy = window.innerHeight;
|
2018-06-24 10:02:09 +02:00
|
|
|
|
|
|
|
updatescr();
|
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
function updatescr() {
|
|
|
|
if (zoomx < 51) {
|
|
|
|
zoomx += 50;
|
|
|
|
}
|
|
|
|
if (zoomy < 51) {
|
|
|
|
zoomy += 50;
|
|
|
|
}
|
|
|
|
let newname = xvb.toString() + " " + yvb.toString() + " " + zoomx.toString() + " " + zoomy.toString();
|
|
|
|
$("#svg1").removeAttr("viewBox");
|
|
|
|
$("#svg1").each(function() { $(this)[0].setAttribute("viewBox", newname) });
|
2018-06-24 10:02:09 +02:00
|
|
|
}
|
2019-10-14 20:00:42 +02:00
|
|
|
document.addEventListener("keydown", e => {
|
|
|
|
if (e.keyCode == 40) {
|
|
|
|
yvb += 10;
|
|
|
|
updatescr();
|
|
|
|
} else if (e.keyCode == 39) {
|
|
|
|
xvb += 10;
|
|
|
|
updatescr();
|
|
|
|
} else if (e.keyCode == 38) {
|
|
|
|
yvb -= 10;
|
|
|
|
updatescr();
|
|
|
|
} else if (e.keyCode == 37) {
|
|
|
|
xvb -= 10;
|
|
|
|
updatescr();
|
|
|
|
} else if (e.keyCode == 187) {
|
|
|
|
if (!(zoomx < 101) && !(zoomy < 101)) {
|
|
|
|
xvb += 25;
|
|
|
|
yvb += 25;
|
|
|
|
}
|
|
|
|
zoomx -= 50;
|
|
|
|
zoomy -= 50;
|
|
|
|
updatescr();
|
|
|
|
} else if (e.keyCode == 189) {
|
|
|
|
xvb -= 25;
|
|
|
|
yvb -= 25;
|
|
|
|
zoomx += 50;
|
|
|
|
zoomy += 50;
|
|
|
|
updatescr();
|
|
|
|
}
|
|
|
|
}, false);
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2018-06-24 10:27:48 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
let zooming = false;
|
|
|
|
let xbeg = 0;
|
|
|
|
let ybeg = 0;
|
|
|
|
let moveing = false;
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
$("svg").on("mousemove touchmove", function(e) {
|
|
|
|
if (moveing && selected == "yay") {
|
|
|
|
if (!(zooming)) {
|
|
|
|
zooming = true;
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
//setting our first mouse poitions
|
|
|
|
xbeg = e.pageX * zoomx / window.innerWidth;
|
|
|
|
ybeg = e.pageY * zoomy / window.innerHeight;
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
xbeg += xvb;
|
|
|
|
ybeg += yvb;
|
|
|
|
//moveing = (moveing +1)%2;
|
|
|
|
}
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
let newx = e.pageX * zoomx / window.innerWidth;
|
|
|
|
let newy = e.pageY * zoomy / window.innerHeight;
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
newx += xvb;
|
|
|
|
newy += yvb;
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
xvb -= newx - xbeg;
|
|
|
|
yvb -= newy - ybeg;
|
|
|
|
updatescr();
|
2018-06-24 10:02:09 +02:00
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
}
|
|
|
|
});
|
2018-06-24 10:02:09 +02:00
|
|
|
|
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
$("svg").on("mousedown touchstart", function() {
|
|
|
|
//e.preventDefault();
|
|
|
|
moveing = true;
|
|
|
|
});
|
2018-06-24 10:02:09 +02:00
|
|
|
|
|
|
|
|
2019-10-14 20:00:42 +02:00
|
|
|
$("svg").on("mouseup touchend", function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
selected = "yay";
|
|
|
|
zooming = false;
|
|
|
|
moveing = false;
|
|
|
|
});
|