/* © 2023 Samuel Bradshaw https://github.com/samuelbradshaw/transcript-tracer-js */ if (window.addEventListener) { window.addEventListener("resize", browserResize); } else if (window.attachEvent) { window.attachEvent("onresize", browserResize); } function browserResize() { fixDragBtn(); } var added = false; var dragging = false; var stack; function fixDragBtn() { var leftpadding, dragleft, buttonwidth var containertop = Number(w3_getStyleValue(document.getElementById("container"), "top").replace("px", "")); leftareasize = Number(w3_getStyleValue(document.getElementById("left-area-wrapper"), "width").replace("px", "")); leftpadding = Number(w3_getStyleValue(document.getElementById("left-area"), "padding-left").replace("px", "")); buttonwidth = Number(w3_getStyleValue(document.getElementById("dragbar"), "width").replace("px", "")); leftareaheight = w3_getStyleValue(document.getElementById("left-area-wrapper"), "height"); dragleft = leftareasize + leftpadding + (leftpadding / 2) - (buttonwidth / 2); document.getElementById("dragbar").style.width = "5px"; document.getElementById("dragbar").style.top = containertop + "px"; document.getElementById("dragbar").style.left = dragleft + "px"; document.getElementById("dragbar").style.height = leftareaheight; document.getElementById("dragbar").style.cursor = "col-resize"; document.getElementById("hello").style.height = "580px"; } function dragstart(e) { e.preventDefault(); dragging = true; } function dragmove(e) { if (dragging) { document.getElementById("shield").style.display = "block"; var percentage = (e.pageX / window.innerWidth) * 100; if (percentage > 5 && percentage < 98) { var mainPercentage = 100-percentage; document.getElementById("left-area-container").style.width = percentage + "%"; document.getElementById("right-area-container").style.width = mainPercentage + "%"; fixDragBtn(); } } } function dragend() { document.getElementById("shield").style.display = "none"; dragging = false; } function initfn() { if (window.addEventListener && document.getElementById("container") != null) { document.getElementById("dragbar").addEventListener("mousedown", function(e) {dragstart(e);}); document.getElementById("dragbar").addEventListener("touchstart", function(e) {dragstart(e);}); window.addEventListener("mousemove", function(e) {dragmove(e);}); window.addEventListener("touchmove", function(e) {dragmove(e);}); window.addEventListener("mouseup", dragend); window.addEventListener("touchend", dragend); window.addEventListener("load", fixDragBtn); } fixDragBtn(); } initfn(); function w3_getStyleValue(elmnt,style) { if (window.getComputedStyle) { return window.getComputedStyle(elmnt,null).getPropertyValue(style); } else { return elmnt.currentStyle[style]; } } fixDragBtn();