Hi there. I have read up on the AnimationManager and looked into scrollToPart, but I can’t seem to get my diagram to nicely animate / transition from one zoom state to another.
Below is the simple function that I’m using to scroll to the selected node and zoom in. Below that, you’ll see my controls for the zoom button. How can I add transitions / animation to the scrollToRect and scale functions?
On a related note, I would ideally like the links to fade to the darker highlight color when selected. Is there any way to add transitions to fade in to the isHighlighted state?
You can see a test version of my diagram at Malnutrition | IRC Theory of Change.
function zoomInToSelectedNode(node){
var nodeKey = node.data.key;
if (node.isSelected){
// Zoom in on node
zoomInButtonClickCount = 2; // zoom level
jq('#zoomIn').trigger('click');
myDiagram.scrollToRect(myDiagram.findNodeForKey(nodeKey).actualBounds);
}
}
// ZOOM CONTROLS
var zoomInButtonClickCount = 1; // number of zooms
var zoomInButtonClickCountMax = 4; // max zoom
var scaleLevelChange = 0.35; // percent zoom
var scaleLevel;
// On zoom in click, zoom in up to 4x
document.getElementById('zoomIn').addEventListener('click', function() {
scaleLevel = scaleLevelChange * zoomInButtonClickCount; // Set scale level to number of times button clicked
// Scale the diagram and center it
myDiagram.scale = scaleLevel;
myDiagram.centerRect(myDiagram.findNodeForKey(1).actualBounds);
// If max limit is reached, disable button
if (zoomInButtonClickCount < zoomInButtonClickCountMax){
document.getElementById('zoomOut').classList.remove('disabled');
zoomInButtonClickCount++;
} else {
this.classList.add('disabled');
zoomInButtonClickCount = 4;
}
});