1 const vf = new ViewFrame();
4 // the event handlers are in iifes so they dont make unneeded globals.
5 // resize, delay re-render to reduce lag.
8 window.addEventListener('resize', () => {
10 id = setTimeout(() => {
19 vf.map.canvas.addEventListener('mousedown', event => {
21 vf.moveCenter(event.pageX, event.pageY);
22 id = setTimeout(() => {
34 vf.map.canvas.addEventListener('mousemove', event => {
35 // only count if the mouse moved more than a chunk
36 let x = Math.floor(vf.x +
37 (event.clientX - vf.width / 2) / vf.zoom);
38 let y = Math.floor(vf.y +
39 (event.clientY - vf.height / 2) / vf.zoom);
40 if (x == lastX && y == lastY) return;
43 vf.updateInfobox(x + '_' + y);
50 vf.map.canvas.addEventListener('wheel', event => {
52 vf.zoom += -Math.sign(event.deltaY)*2;
53 id = setTimeout(() => {
59 // reload the chunk list every six seconds
60 var devBlockReload = false; // disable via command line
63 if (devBlockReload) return;