-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node label flickering when animating font-size #3270
Comments
By "blinking" you are referring to the non-smooth resizing animation that sometimes happens? |
Removed the workaround in this comment because there is a better one below... |
I’ve managed to diagnose the problem. The bug can be triggered just by animating the font size, and you only need one node. It has nothing to do with mouse inputs or hovering. I created a looping animation with a single node like this… var node = cy.getElementById('a');
var expand = true;
var duration = 1000;
var timeout = duration + 100;
function testAnimate() {
if(expand) {
node.animate({
style: {
'font-size': '12px',
},
duration: duration,
queue: false,
});
expand = false;
} else {
node.animate({
style: {
'font-size': '10px',
},
duration: duration,
queue: false,
});
expand = true;
}
setTimeout(testAnimate, timeout);
}
setTimeout(testAnimate, timeout); Eventually the weird flickering behaviour will start to show up. The problem is that animating the font size like this causes the renderer’s The reason the flicker happens is because of a cache collision. It calculates a cache key which just happens to be shared with a different label size, and pulls the wrong dimensions from the cache. That frame of the animation gets the wrong label size and that causes the flicker. I’m going to hand this one off to @maxkfranz for now, as he is way more familiar with the style hashing code. I’m not sure why the hashes are colliding and I would need some time to dig through the code to understand it. In the meantime there is a workaround. Add a node.animate({
style: {
'font-size': '10px',
},
duration: duration,
queue: false,
complete: () => { cy.renderer().labelDimCache = []; } // clear the label dimensions cache
}); That will clear out the cache after each animation. Warning, the |
Thank you, @mikekucera, for your diagnostic. flickering.mp4 |
Environment info
Current (buggy) behaviour
What does the bug do?
When I try to add a hover effect to a node to enlarge the font size, the node's label blinks. Specifically, when I hover over one node, the label of another node or both nodes start blinking.
node.blinking.mp4
Desired behaviour
What do you expect Cytoscape.js to do instead?
Node labels should remain stable and not blink when hovering over another node.
Minimum steps to reproduce
What do you need to do to reproduce the issue?
The issue is reproduced here: https://jsbin.com/narayik/edit?html,css,js,output
Fork/clone this JSBin demo and reproduce your issue so that your issue can be addressed quickly and effectively:
http://jsbin.com/fiqugiq
For reviewers
Reviewers should ensure that the following tasks are carried out for incorporated issues:
master
,unstable
, and1.1.x
if the current release is 1.2).bug
, if necessary.The text was updated successfully, but these errors were encountered: