Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/js/action/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,19 @@ export function draw_metarelation(draw_context, mei_graph, g_elem) {
var type = relation_type(g_elem)
// Get the targets - we don't differentiate primaries and secondaries in
// this drawing style.
var targets = relation_allnodes(mei_graph, g_elem).map(
(e) => document.getElementById(draw_context.id_prefix + get_id(e)))
// TODO should be possible to draw partial metarelations
if (targets.indexOf(null) != -1) {
var targets = relation_allnodes(mei_graph, g_elem).map((e) => {
let he = document.getElementById(draw_context.id_prefix + get_id(e))
if (!he) return
return he.classList.contains('hidden-reduced') ? null : he
})
if (!targets[0]) {
console.log('Missing relation, not drawing metarelation')
return []
}

const isDownward = targets.every(target => target.getAttribute('is-downward') === 'true')
const isDownward = targets.every(
target => target.getAttribute('is-downward') === 'true'
)

// Where are our targets
var coords = targets.map(target => {
Expand Down
9 changes: 7 additions & 2 deletions src/js/modules/Score/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class Score {
// Cached members.

get flatSelection() {
return this.#cache.remember('flatSelection', () => Object.values(this.selection).flat())
return this.#cache.remember('flatSelection',
() => this.selection
? Object.values(this.selection).flat()
: null)
}

get hasSelection() {
Expand All @@ -46,7 +49,9 @@ class Score {
get selectionType() {
return this.#cache.remember('selectionType', () => {
return SELECTABLE_TYPES.find(type => {
return this.flatSelection[0]?.classList.contains(type)
return this.flatSelection
? this.flatSelection[0]?.classList.contains(type)
: null
}) ?? null
})
}
Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ export function id_in_svg(draw_context, id) {
// that's how it is), then dc.id_prefix to calculate the final id
var layer_id = id_in_layer(draw_context.layer, id)
var svg_note = document.getElementById(layer_id)
if (svg_note && svg_note.classList.contains('hidden-reduced'))
return null
if (draw_context.svg_elem.contains(svg_note))
return layer_id
if (layer_id)
Expand Down