embiem / react-canvas-draw

React Component for drawing in canvas
https://embiem.github.io/react-canvas-draw/
MIT License
892 stars 315 forks source link

Use z-index of parent instead of hard-coding #79

Closed curlywurlycraig closed 2 years ago

curlywurlycraig commented 4 years ago

What is this?

This change uses the natural indexing rules of the browser by ordering canvas elements, rather than specifying a hard-coded z-index. This fixes issues relating to absolutely positioned canvases.

Context

I'm building a fun react-app that allows the moving around of little drawings on a kind of pin-board. Without this change, overlapping elements don't correctly obey the z-index of their parents, resulting in some weird visual issues:

Screenshot 2020-05-02 at 12 43 30

But with this change, the CanvasDraw elements correctly obey their parents z-index:

Screenshot 2020-05-02 at 12 42 02
embiem commented 2 years ago

Thanks for catching that & contributing!!

curlywurlycraig commented 2 years ago

You're welcome!