fix: render drakonwidget at 480x360 to fit container properly
This commit is contained in:
1 parent
7721d7b49b
commit
98fee5677d
1 file changed
+17
-11
+17
-11
@@ -879,6 +879,12 @@ button { font-family: inherit; cursor: pointer; border: none; background: none;
|
|||||||
|
|
||||||
#drakon-canvas > div {
|
#drakon-canvas > div {
|
||||||
transform-origin: center center;
|
transform-origin: center center;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
#drakon-canvas > div > canvas {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#drakon-canvas canvas {
|
#drakon-canvas canvas {
|
||||||
@@ -1325,13 +1331,12 @@ window.addEventListener('load', function() {
|
|||||||
var canvasContainer = document.getElementById('drakon-canvas');
|
var canvasContainer = document.getElementById('drakon-canvas');
|
||||||
var widget = createDrakonWidget();
|
var widget = createDrakonWidget();
|
||||||
|
|
||||||
// Set up canvas with explicit dimensions
|
// Set up canvas with explicit dimensions matching container (480x360 fits in ~486px container)
|
||||||
// width/height define the diagram coordinate system
|
widget.render(480, 360, {
|
||||||
widget.render(560, 420, {
|
|
||||||
startEditContent: function() { /* read-only — no edit */ },
|
startEditContent: function() { /* read-only — no edit */ },
|
||||||
showContextMenu: function() { /* read-only */ },
|
showContextMenu: function() { /* read-only */ },
|
||||||
canSelect: false,
|
canSelect: false,
|
||||||
maxWidth: 560,
|
maxWidth: 480,
|
||||||
theme: drakonTheme
|
theme: drakonTheme
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1342,14 +1347,15 @@ window.addEventListener('load', function() {
|
|||||||
if (widget.container) {
|
if (widget.container) {
|
||||||
canvasContainer.appendChild(widget.container);
|
canvasContainer.appendChild(widget.container);
|
||||||
|
|
||||||
// Scale the container to fit the parent (560px canvas -> fit in ~486px container)
|
// Scale the container to fit the parent (480px canvas -> fit in ~486px container)
|
||||||
var containerWidth = canvasContainer.clientWidth;
|
var containerWidth = canvasContainer.clientWidth;
|
||||||
var scaleX = containerWidth / 560;
|
var scaleX = containerWidth / 480;
|
||||||
var scaleY = (containerWidth / 560) * (420 / 400);
|
widget.container.style.position = 'relative';
|
||||||
widget.container.style.transform = 'scale(' + scaleX + ')';
|
widget.container.style.left = '50%';
|
||||||
widget.container.style.transformOrigin = 'center center';
|
widget.container.style.transform = 'translateX(-50%) scale(' + scaleX + ')';
|
||||||
widget.container.style.width = (560 * scaleX) + 'px';
|
widget.container.style.width = (480 * scaleX) + 'px';
|
||||||
widget.container.style.height = (420 * scaleX) + 'px';
|
widget.container.style.height = (360 * scaleX) + 'px';
|
||||||
|
widget.container.style.overflow = 'visible';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user