Skip to content

Commit 2f7ff4e

Browse files
committed
fix: move adjustSvgDimension in do actions
- Ensured that `adjustSvgDimension` is called after drawing complete - Added 100px offset to y dimension refs: #277 (comment)
1 parent b3a0180 commit 2f7ff4e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/js/app.js

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { debug } from './conf'
1515

1616
import newApp from './new/app'
1717
import { downloadAs } from './new/utils/file'
18+
import { adjustSvgDimensions } from './ui'
1819

1920
// Clicking selects, exposed globally
2021
window.selected = []
@@ -200,6 +201,8 @@ export function do_relation(type, id, redoing = false) {
200201

201202
// Update hierarchy tree if visible
202203
window.relationTreeInstance?.updateIfVisible()
204+
205+
adjustSvgDimensions(getCurrentDrawContext())
203206
}
204207

205208
export function do_comborelation(type) {
@@ -253,6 +256,8 @@ export function do_metarelation(type, id, redoing = false) {
253256

254257
// Update hierarchy tree if visible
255258
window.relationTreeInstance?.updateIfVisible()
259+
260+
adjustSvgDimensions(getCurrentDrawContext())
256261
}
257262

258263
var rerendered_after_action
@@ -634,6 +639,7 @@ function finalize_draw_context(new_draw_context) {
634639
console.groupEnd()
635640
draw_graph(new_draw_context)
636641
setCurrentDrawContext(new_draw_context)
642+
adjustSvgDimensions(new_draw_context)
637643
}
638644

639645
function render_mei(mei) {

src/js/draw.js

-6
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ export function draw_relation(draw_context, mei_graph, g_elem) {
115115
// Remember what we're adding
116116
added.push(group)
117117

118-
// Adjust SVG dimensions if needed
119-
adjustSvgDimensions(draw_context)
120-
121118
return added
122119
}
123120

@@ -426,8 +423,5 @@ export function draw_metarelation(draw_context, mei_graph, g_elem) {
426423
// Remember what we're adding
427424
added.push(g_elem)
428425

429-
// Adjust SVG dimensions if needed
430-
adjustSvgDimensions(draw_context)
431-
432426
return added
433427
}

src/js/ui.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ export const setCurrentDrawContext = drawContext => {
555555
}
556556

557557
export function adjustSvgDimensions(draw_context) {
558+
console.trace('adjustSvgDimensions')
558559
const svg_elem = draw_context.svg_elem
559560
const rootSvg = svg_elem.getElementsByTagName('svg')[0]
560561
const definitionScale = svg_elem.getElementsByClassName('definition-scale')[0]
@@ -611,5 +612,5 @@ export function adjustSvgDimensions(draw_context) {
611612

612613
// Set the width and height on the container SVG in pixels
613614
rootSvg.setAttribute('width', `${newPixelWidth}px`)
614-
rootSvg.setAttribute('height', `${newPixelHeight}px`)
615+
rootSvg.setAttribute('height', `${newPixelHeight + 100}px`)
615616
}

0 commit comments

Comments
 (0)