N°3911 Allow datamodel viewer graph to be horizontally scrolled when overflowing out of page

This commit is contained in:
Stephen Abello
2021-10-25 15:34:52 +02:00
parent ab23ea1da0
commit f8c59e6171

View File

@@ -811,7 +811,27 @@ field.filter(function(d) {
.attr("height", 36)
.attr("xlink:href", function(d, i) { return d.icon })
.attr("transform", "translate(-12, -24)");
// When the schema is visible for the first time, initialize SVG viewbox based on content height/width
let oSvgElement = document.getElementsByClassName("dataModelSchema")[0];
if(window.IntersectionObserver) {
const oDatamodelSchemaIntersectObs = new IntersectionObserver(function(aEntries, oDatamodelSchemaIntersectObs){
aEntries.forEach(oEntry => {
let bIsVisible = oEntry.isIntersecting;
if(bIsVisible) {
let oSvgBB = oSvgElement.getBBox();
let aSvgViewbox = [oSvgBB.x, oSvgBB.y , oSvgBB.width, oSvgBB.height];
oSvgElement.setAttribute("viewBox", aSvgViewbox.join(" "));
oDatamodelSchemaIntersectObs.unobserve(oSvgElement);
}
});
}, {
root: $('#dataModelGraph')[0],
threshold: [1] // Must be completely visible
});
oDatamodelSchemaIntersectObs.observe(oSvgElement);
}
JS
);
}