fix: fixed-size canvas + reliable init

This commit is contained in:
neo committed 2026-06-23 17:27:43 +05:00
1 parent 5e692733b7
commit 64294daa60
1 file changed
+6 -8
+6 -8
View File
@@ -270,6 +270,7 @@ button { font-family: inherit; cursor: pointer; border: none; background: none;
#drakon-canvas {
width: 100%;
height: 420px;
position: relative;
}
@media (max-width: 768px) {
@@ -1415,7 +1416,7 @@ function initDrakonDiagram() {
// Minimal view-only configuration
var config = {
startEditContent: function () { /* read-only — no edit */ },
startEditContent: function () { /* read-only */ },
showContextMenu: function () { /* read-only */ },
canSelect: false,
maxWidth: 320,
@@ -1447,15 +1448,12 @@ function initDrakonDiagram() {
// Build widget
var drakonCanvas = document.getElementById('drakon-canvas');
var drakon = createDrakonWidget();
var WIDGET_W = 560;
var WIDGET_H = 420;
function rebuildWidget() {
var rect = drakonCanvas.getBoundingClientRect();
drakonCanvas.innerHTML = '';
var widgetEl = drakon.render(
rect.width || 600,
rect.height || 420,
config
);
var widgetEl = drakon.render(WIDGET_W, WIDGET_H, config);
drakonCanvas.appendChild(widgetEl);
}
@@ -1479,7 +1477,7 @@ function initDrakonDiagram() {
sender,
false
);
}, 100);
}, 200);
// Handle resize
var resizeObserver = new ResizeObserver(function () {