File size: 2,955 Bytes
3a6bdbe 48cf9d5 3a6bdbe 48cf9d5 3a6bdbe 863f2c8 3a6bdbe 766271a 3a6bdbe 0a8ae5a 3a6bdbe d901a31 c0efa28 d901a31 3a6bdbe 07d713d 3a6bdbe 41c463c dd7b253 3a6bdbe eec3eb9 41c463c b29da53 3a6bdbe 3ebffdf 5af4e8b 54f954e 5af4e8b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
/*
© 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();
|