Skip to content

Visibility and emphasis

Inspect visibility and core-owned emphasis state.

#ele.visible()

// Whether the first element renders (the derived FLAGDRAWN — shown AND not visibility: 'hidden' on self or, for nodes, any ancestor; edges additionally fold their endpoints)
ele.visible(): boolean

Whether the first element renders (the derived FLAG_DRAWN — shown AND not visibility: 'hidden' on self or, for nodes, any ancestor; edges additionally fold their endpoints). The renderer's cull pass and CPU picking mask on the same bit, so an element that is not visible() neither draws nor picks. For space-tier state (in the bb, sizing its compound parent) see takesUpSpace() — an invisible element keeps its space.

Returns boolean

whether the element draws and picks; false for a removed element, for an edge either of whose endpoints is hidden, and for a node under a hidden or invisible ancestor

Example

console.log(eles.visible()); // true

Example graph and handle setup

#ele.hidden()

// The complement of visible()
ele.hidden(): boolean

The complement of visible().

Returns boolean

true when the first element does not draw

Example

console.log(eles.hidden()); // false

Example graph and handle setup

#eles.show()

// Show these elements — the display tier
eles.show(): this

Show these elements — the display tier. Shown elements take up space again, rejoin bounds and fit, and re-fan their bezier bundles.

For paint-only invisibility that keeps space and bundle ranks, use the visibility style property instead, and for a fade use an opacity transition.

Returns this

this collection, for chaining

Example

const node = cy.getElementById('a');
node.show();
console.log(node.visible()); // true

Example graph and handle setup

#eles.hide()

// Hide these elements structurally
eles.hide(): this

Hide these elements structurally. They stop drawing and picking, leave the bounding box and their ancestors' auto-bounds, and their bezier bundles re-fan without them. Descendants of a hidden node are gated too.

Returns this

this collection, for chaining

Example

const node = cy.getElementById('a');
node.hide();
console.log(node.hidden()); // true

Example graph and handle setup

#ele.emphasized()

// Whether the first element is in the current emphasis — the set the last cy.emphasize( eles) named
ele.emphasized(): boolean

Whether the first element is in the current emphasis — the set the last cy.emphasize( eles) named.

Returns boolean

the element's emphasized flag; false for a removed element and while no emphasis is set. An element outside a set emphasis is the one the renderer dims — derived, so there is no dimmed()

Example

console.log(eles.emphasized()); // false

Example graph and handle setup

All guides · Alphabetical API index · Read continuously