You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to disable the ability to resize a node if the map is zoomed out far enough, so as to prevent accidental resizing. I tried to implement this using the isNoControlsMode function provided during initialization: isNoControlsMode: function(node){ var z = cy.zoom(); var cyW = cy.container().clientWidth; var cyH = cy.container().clientHeight; var nW = node.width(); var nH = node.height(); if((nW*nH*z)/(cyW*cyH) < .0005 ){ return true } return false }
This approach works sometimes, but for some reason it is very finnicky. I'm wondering if this is the correct approach for such a problem/if I am misusing is isNoControlsMode function?
The text was updated successfully, but these errors were encountered:
Hello @cbisaccia78. I think this would be the right approach.
The reason it might be "finnicky" as you suggested might be because of the difference between model positions and rendered positions. Your cy.container().clientWidth will give you the container DOM object's width, whereas node.width() will give you the model width of the node. More about cytoscape position logic here.
I suggest you use either rendered sizes of both the cytoscape container and nodes (maybe use eles.renderedBoundingBox()) or the model sizes of both with cy.extent() and test that way.
I want to disable the ability to resize a node if the map is zoomed out far enough, so as to prevent accidental resizing. I tried to implement this using the isNoControlsMode function provided during initialization:
isNoControlsMode: function(node){
var z = cy.zoom();
var cyW = cy.container().clientWidth;
var cyH = cy.container().clientHeight;
var nW = node.width();
var nH = node.height();
if((nW*nH*z)/(cyW*cyH) < .0005 ){
return true
}
return false
}
This approach works sometimes, but for some reason it is very finnicky. I'm wondering if this is the correct approach for such a problem/if I am misusing is isNoControlsMode function?
The text was updated successfully, but these errors were encountered: