Skip to content

Commit 9c61163

Browse files
committed
Prevent editors from sticking out of window when growing
1 parent 7a5fc23 commit 9c61163

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: html/js/ejs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ window.addEventListener("load", function() {
5858
};
5959

6060
var nextID = 0;
61+
var article = document.getElementsByTagName("article")[0];
6162

6263
function activateCode(node, e, lang) {
6364
var code = node.textContent;
@@ -69,7 +70,7 @@ window.addEventListener("load", function() {
6970
matchBrackets: true,
7071
lineNumbers: true
7172
});
72-
wrap.style.margin = "1rem -5em";
73+
wrap.style.marginLeft = wrap.style.marginRight = -Math.min(article.offsetLeft, 100) + "px";
7374
setTimeout(function() { editor.refresh(); }, 600);
7475
if (e) {
7576
editor.setCursor(editor.coordsChar({left: e.clientX, top: e.clientY}, "client"));

0 commit comments

Comments
 (0)