menu refactor

This commit is contained in:
simon 2019-05-21 21:14:08 -04:00
parent 6cc15d6865
commit 6558cf5a22

View File

@ -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) => {