question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of zIndex property

See original GitHub issue

In pure Konva framework, we have zIndex property. It is very useful to change order of elements with that property:

node.setZIndex(2);

In react-konva the order of elements will be defined as it is defined in render() function of a component:

// Rect will have zIndex = 0
// Circle will have zIndex = 1
const Component = () =>
   <Group>
     <Rect>
     <Circle>
   <Group>


// Rect will have zIndex = 1
// Circle will have zIndex = 0
const Component2 = () =>
   <Group>
     <Circle>
     <Rect>
   <Group>

We may have unexpected result if we will use two logics of ordering at the same time:

const Component = () =>
   <Group>
     <Rect zIndex={1}>
     <Circle>
   <Group>

So my suggestion is to NOT use zIndex attrube in react-konva. Just reorder nodes in render().

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lavrtoncommented, Mar 25, 2019

No, we don’t need to rever the order from react-konva side. If you need to revert it, you can do it manually from your render() function.

0reactions
lavrtoncommented, Jun 27, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS z-index property - W3Schools
The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element...
Read more >
Using z-index - CSS: Cascading Style Sheets - MDN Web Docs
When no z-index property is specified, elements are rendered on the default rendering layer (Layer 0). · If several elements share the same...
Read more >
z-index - CSS-Tricks
The z-index property in CSS controls the vertical stacking order of elements that overlap. As in, which one appears as if it is...
Read more >
The Z-Index CSS Property: A Comprehensive Look
The z-index property determines the stack level of an HTML element. The “stack level” refers to the element's position on the Z axis...
Read more >
Z Index in CSS: What it Is and What it Does - freeCodeCamp
Z Index ( z-index ) is a CSS property that defines the order of overlapping HTML elements. Elements with a higher index will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found