mirror of
https://github.com/simon987/music-graph-ui.git
synced 2025-04-19 18:16:41 +00:00
menu refactor
This commit is contained in:
parent
6cc15d6865
commit
6558cf5a22
@ -184,22 +184,15 @@ export function MusicGraph(data) {
|
|||||||
.append('title')
|
.append('title')
|
||||||
.text(item => item.title)
|
.text(item => item.title)
|
||||||
|
|
||||||
const angleOffset = items.length === 3 ? 3.72 : 3.927 // Don't ask
|
const centroid = (idx, rad) => arc(rad, idx, items.length, 30).centroid()
|
||||||
this.menu
|
this.menu
|
||||||
.append('g')
|
.append('g')
|
||||||
.html(d => d.icon)
|
.html(d => d.icon)
|
||||||
.classed('menu-icon', true)
|
.classed('menu-icon', true)
|
||||||
.attr('transform', d =>
|
.attr('transform', d => `translate(${centroid(d.idx, 1)[0] - 13}, ${centroid(d.idx, 1)[1] - 13})`)
|
||||||
`translate(${40 * Math.cos(2 * Math.PI * d.idx / items.length + angleOffset) - 10},
|
|
||||||
${40 * Math.sin(2 * Math.PI * d.idx / items.length + angleOffset) - 10})`
|
|
||||||
)
|
|
||||||
.transition()
|
.transition()
|
||||||
.duration(250)
|
.duration(250)
|
||||||
.attr('transform', d =>
|
.attr('transform', d => `translate(${centroid(d.idx, 35)[0] - 10}, ${centroid(d.idx, 35)[1] - 10})`)
|
||||||
`translate(
|
|
||||||
${57 * Math.cos(2 * Math.PI * d.idx / items.length + angleOffset) - 10},
|
|
||||||
${57 * Math.sin(2 * Math.PI * d.idx / items.length + angleOffset) - 10})`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nodeDbClick = (d) => {
|
this.nodeDbClick = (d) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user