Skip to content
Snippets Groups Projects
Commit f5857968 authored by Marcelo Querino Lima Alfonso's avatar Marcelo Querino Lima Alfonso
Browse files

added highlight animation

parent f47574c5
No related branches found
No related tags found
1 merge request!5Refactored code for diplaying aggregated ligand interactions
......@@ -385,13 +385,47 @@ class Depiction {
private highlightAtom(element) {
this.removeHighlights();
const data = this.atoms;
const radiusScale = d3.scaleLinear(
[0, d3.max(data.map(x => x.value))],
[15, 30]
)
d3.select(element)
.style("stroke", "#E275E5")
.style("stroke-width", 5);
.classed("selectedCircle", true)
.classed("isAnimating", true)
.style("stroke", "#FBBD1D")
.style("stroke-width", 5);
function animateStroke() {
if (d3.select('.selectedCircle').classed("isAnimating")) {
d3.select('.selectedCircle').transition()
.duration(500) // 500 milliseconds
.style("stroke-width", 10)
.attr("r", (d:Atom) => radiusScale(d.value)*1.3) // Double the size
.transition()
.duration(500) // 500 milliseconds
.style("stroke-width", 5)
.attr("r", (d:Atom) => radiusScale(d.value))// Revert to original size
.on("end", animateStroke)
}
}
animateStroke();
}
private removeHighlights(){
d3.selectAll(".weightCircles")
const data = this.atoms;
const radiusScale = d3.scaleLinear(
[0, d3.max(data.map(x => x.value))],
[15, 30]
)
d3.selectAll(".selectedCircle")
.classed("selectedCircle", false)
.classed("isAnimating", false)
.interrupt()
.attr("r", (d:Atom) => radiusScale(d.value))
.style("stroke", null);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment