diff --git a/static/watch.css b/static/watch.css index 3e389ddbb..e89729739 100644 --- a/static/watch.css +++ b/static/watch.css @@ -1,3 +1,13 @@ +body { + margin: 0; +} + +#d2-svg-container > svg { + position: absolute; + width: 100%; + height: 100%; +} + #d2-err { /* This style was copied from Chrome's svg parser error style. */ white-space: pre-wrap; diff --git a/static/watch.js b/static/watch.js index 44fff3821..1b21f801f 100644 --- a/static/watch.js +++ b/static/watch.js @@ -11,8 +11,6 @@ function init(reconnectDelay) { const ws = new WebSocket( `ws://${window.location.host}${window.location.pathname}watch` ); - let isInit = true; - let ratio; ws.onopen = () => { reconnectDelay = 1000; console.info("watch websocket opened"); @@ -33,27 +31,6 @@ function init(reconnectDelay) { // setting innerHTML to only the actual svg innards. However then you also need to parse // out the width, height and viewbox out of the top level SVG tag and update those manually. d2SVG.innerHTML = msg.svg; - - const svgEl = d2SVG.querySelector("#d2-svg"); - let width = parseInt(svgEl.getAttribute("width"), 10); - let height = parseInt(svgEl.getAttribute("height"), 10); - if (isInit) { - if (width > height) { - if (width > window.innerWidth) { - ratio = window.innerWidth / width; - } - } else if (height > window.innerHeight) { - ratio = window.innerHeight / height; - } - // Scale svg fit to zoom - isInit = false; - } - if (ratio) { - // body padding is 8px - svgEl.setAttribute("width", width * ratio - 16); - svgEl.setAttribute("height", height * ratio - 16); - } - d2ErrDiv.style.display = "none"; } if (msg.err) {