Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>Test for the pane-splitter custom element</title>
<style>
hr[is="pane-splitter"] {
margin: 0 -3px;
border: none;
z-index: 1;
cursor: ew-resize;
opacity: .4;
background-color: red;
}
#splitter3,
#splitter4 {
margin: -3px 0;
cursor: ns-resize;
}
#horizontal-before {
display: grid;
grid-template-columns: minmax(auto, var(--splitter1-width)) 0 auto;
width: 500px;
height: 100px;
--splitter1-width: 200px;
margin: 1em;
}
#horizontal-after {
display: grid;
grid-template-columns: auto 0 minmax(auto, var(--splitter2-width));
width: 500px;
height: 100px;
--splitter2-width: 200px;
margin: 1em;
}
#vertical-before {
display: inline-grid;
grid-template-rows: minmax(auto, var(--splitter3-height)) 0 auto;
width: 100px;
height: 500px;
--splitter3-height: 200px;
margin: 1em;
}
#vertical-after {
display: inline-grid;
grid-template-rows: auto 0 minmax(auto, var(--splitter4-height));
width: 100px;
height: 500px;
--splitter4-height: 200px;
margin: 1em;
}
.resized {
background-color: lightblue;
}
.fill {
background-color: lightslategrey;
}
</style>
<!-- This path is used for the automated test. -->
<!-- This path is used when this file is loaded in a browser. -->
<script src="../../../content/widgets/pane-splitter.js"></script>
<script>
function moveMarker(event) {
let markerX = document.getElementById("markerX");
markerX.style.left = `${event.clientX + window.scrollX}px`;
markerX.textContent = `${event.type} event here`;
let markerY = document.getElementById("markerY");
markerY.style.top = `${event.clientY + window.scrollY}px`;
markerY.textContent = `${event.type} event here`;
}
document.addEventListener("mousedown", moveMarker);
document.addEventListener("mousemove", moveMarker);
document.addEventListener("mouseup", moveMarker);
window.addEventListener("load", () => {
for (let splitter of document.querySelectorAll('hr[is="pane-splitter"]')) {
splitter.resizeElement = splitter.parentNode.querySelector(".resized");
}
});
</script>
</head>
<body>
<div id="horizontal-before">
<div id="splitter1-before" class="resized"></div>
<hr is="pane-splitter" id="splitter1" resize-direction="horizontal" />
<div id="splitter1-after" class="fill"></div>
</div>
<div id="horizontal-after">
<div id="splitter2-before" class="fill"></div>
<hr is="pane-splitter" id="splitter2" resize="next" resize-direction="horizontal" />
<div id="splitter2-after" class="resized"></div>
</div>
<div style="display: flex;">
<div id="vertical-before">
<div id="splitter3-before" class="resized"></div>
<hr is="pane-splitter" id="splitter3" />
<div id="splitter3-after" class="fill"></div>
</div>
<div id="vertical-after">
<div id="splitter4-before" class="fill"></div>
<hr is="pane-splitter" id="splitter4" resize="next" />
<div id="splitter4-after" class="resized"></div>
</div>
</div>
<div id="markerX" style="position: absolute; top: 0px; border-left: 1px red solid;"></div>
<div id="markerY" style="position: absolute; left: 550px; border-top: 1px red solid;"></div>
</body>
</html>