I created the spotlight using react js. I am not able to click the objects below it. I tried to apply pointerEvents: 'none' to the styling but that doesn't move the spotlight. How should I make the objects below clickable?
Here is the code:-
import React from 'react';
export default class Spot extends React.Component {
constructor(props) {
super(props);
this.state = { x: 0, y: 0};
}
_onMouseMove(e) {
this.setState({ x: e.screenX , y: e.screenY });
}
render() {
const { x, y } = this.state;
return (
<div className={'spot'} onMouseMove={this._onMouseMove.bind(this)}
style={{background: `radial-gradient(${this.props.height}px
${this.props.width}px at ${x}px ${y}px , transparent 90%,
${this.props.color})`, top: '0', bottom: '0', left: '0', right:
'0', position: 'absolute'}}>
</div>
);
}
}
Here is the other component:-
import React from 'react'
import Scene from '../components/Scene'
import Sobject from '../components/Object'
import Room from '../images/level1/Room.png'
import Spot from './Spotlight.js'
export default class Level1 extends React.Component {
constructor(props) {
super(props)
}
clickIt(){
console.log('room')
}
render() {
return (
<div>
<Scene>
<Sobject name={'room'} xPos={0} yPos={0}>
<img src={Room} height="725" width="1536" onClick=
{this.clickIt.bind(this)} />
</Sobject>
<Spot height={200} width={200} color={'rgba(0,0,0,0.91)'} />
</Scene>
</div>
)
}
}