test3 = {
const svg = d3.create('svg')
.attr('viewBox', [-width/2, -width/4, width, width/2])
const side_length = 200
const square = svg.append('rect')
.attr('x', -side_length/2)
.attr('y', -side_length/2)
.attr('width', side_length)
.attr('height', side_length)
.attr('r', 100)
.style('fill', 'black')
const popOutDuration = 1000
const restoreDuration = 250
const squareRotationDuration = 1000
let circle = new PopOutCircle({
popOutDuration: popOutDuration,
restoreDuration: restoreDuration,
restoreDelay: popOutDuration + squareRotationDuration
})
svg.append(() => circle.node())
function update() {
circle.popOut()
square.transition()
.delay(popOutDuration)
.duration(squareRotationDuration)
.attr('transform', `rotate(${d3.randomUniform(0,360)()})`)
circle.restore()
}
Object.assign(svg.node(), {update})
return svg.node()
}