Skip to content

Commit 4fc3611

Browse files
author
Ryan Nixon Salim
committed
add zIndex options
1 parent 2e2f8f1 commit 4fc3611

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/components/InfinityGauntlet.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ function handleSnap(imgRef, particleRefs, setState, state, snap) {
6565
}
6666

6767
function InfinityGauntlet(props) {
68+
const { options, snap } = props;
6869
const wrapperRef = useRef();
6970
const [state, setState] = useState('visible');
7071
const particleRefs = useRef([...Array(canvasCount)].map(() => createRef()));
71-
const canvases = generateBlankCanvas(particleRefs, state, canvasCount);
72+
const zIndex = options.zIndex || 2;
73+
const canvases = generateBlankCanvas(particleRefs, state, canvasCount, zIndex);
74+
7275
useEffect(() => {
73-
handleSnap(wrapperRef, particleRefs, setState, state, props.snap);
74-
}, [props.snap]);
76+
handleSnap(wrapperRef, particleRefs, setState, state, snap);
77+
}, [snap]);
7578

7679
return (
7780
<div style={{ position: 'relative' }}>
78-
<OriginalElement pose={state} ref={wrapperRef} style={{ position: 'absolute', zIndex: 1 }}>
81+
<OriginalElement pose={state} ref={wrapperRef} style={{ position: 'absolute', zIndex }}>
7982
{props.children}
8083
</OriginalElement>
8184
<CanvasContainer pose={state}>{canvases}</CanvasContainer>

src/helper/Util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ export function createBlankImageData(imageData, canvasCount) {
2525
return imageDataArray;
2626
}
2727

28-
export function generateBlankCanvas(refs, state, canvasCount) {
28+
export function generateBlankCanvas(refs, state, canvasCount, zIndex) {
2929
const canvases = [];
3030
for (let a = 0; a < canvasCount; a++) {
3131
const canvasStyle = {
3232
position: 'absolute',
33+
zIndex: zIndex - 1,
3334
};
3435

3536
const dustProps = {

0 commit comments

Comments
 (0)