Trigger an "onMouseMove" event when the "pointer-events-none" css property is applied to fire

Currently, I am dealing with a React Component that contains an absolutely positioned div overlaying other content within my application. This particular div is utilized to trigger react's onMouseMove event.

My objective is to apply the CSS value pointer-events-none so that all components beneath the div remain clickable and responsive to pointer events. However, the challenge arises when having pointer-events-none present causes the onMouseMove event not to function anymore. Essentially, I want everything to behave as if the overlay div wasn't there, allowing only the onMouseMove event to be triggered.

The code structure in question is outlined below:

<button>I should be clickable</button>
<div>
  <div
    style={{
      opacity: 0,
      position: `absolute`,
      top: `50px`,
      left: `50px`,
      width: `30vw`,
      height: `30vh`,
      pointerEvents: `none`,
    }}
    onMouseMove={() => {
      console.log(`Fire!`)
    }}
  >
    Overlay
  </div>
  <button>I should be clickable</button>
  <a>I should be clickabel</a>
</div>
<button>I should be clickable</button>

I believe I may have overlooked something or possibly taken the wrong approach. Any guidance provided would be greatly appreciated!

Answer №1

To ensure the content inside a div is visible, place an overlay div at the root and allow events to propagate by removing pointerEvents rule and opacity:

<div
  style={{
    position: `absolute`,
    top: `50px`,
    left: `50px`,
    width: `30vw`,
    height: `30vh`
  }}
  onMouseMove={() => {
    console.log(`Fire!`)
  }}
>
  <button>I should be clickable</button>
  <button>I should be clickable</button>
  <a>I should be clickable</a>
  <button>I should be clickable</button>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for eliminating Ref upon exiting the screen on React / React Native?

When navigating back in React / React Native, I am encountering keyboard flickering caused by the presence of Ref on the screen. I would like to remove it before leaving the screen. The code snippet I am using is as follows: // To focus on the input fie ...

Problem with Ext.net TabPanel

I am encountering a problem with the Ext.net TabPanel. Every time the page containing the tab panel is opened for the first time after the application has been rebuilt, it throws an error Uncaught TypeError: Object [object Object] has no method 'getCo ...

Nuxtjs is functioning properly on 127.0.0.1:5000, but unfortunately it is not working on localhost:5000

Currently, I'm working on a project with Nuxtjs. The application opens successfully when I use the URL 127.0.0.1. However, when I attempt to access it through localhost:5000, I receive the error message Access to localhost was denied. You don't h ...

What is the best way to resize SVG graphics effectively?

I am in need of creating a seating chart. I have generated an SVG with the seats. <div class="seats-map"> <svg xmlns="https://www.w3.org/2000/svg" id="seats-map-svg" viewBox="0 0 1000 300"> <g data-row ...

Issues with CSS Min-Height in Various Web Browsers

Lately, I've been working on a website and trying to create a border that surrounds all my content and extends the full length of the page. The #Container div is supposed to expand to fill the entire page. I've tried using min-height:100%; in my ...

Semantic-ui-react cannot be located by Docker

I am a beginner when it comes to docker and I'm looking to create a React app, specifically using TypeScript, inside a docker container. In order to do this, I need to incorporate semantic-ui-react into my project. I followed the instructions provide ...

Vue.js - computed property not rendering in repeated list

It seems like the issue lies in the timing rather than being related to asynchronous operations. I'm currently iterating through an object and displaying a list of items. One of the values requires calculation using a method. While the direct values ...

Creating a text-only fadein/fadeout carousel using JavaScript with a similar functionality to Bootstrap

Is there a way to create a fade-in/fade-out text only carousel similar to the one on the header of this website using just a few lines of CSS and Javascript instead of including the whole Bootstrap framework? I examined the code of the website and it appe ...

What could be causing the React text input to constantly lose focus with every keystroke?

In my React project using Material-UI library, I have a component called GuestSignup with various input fields. const GuestSignup = (props: GuestSignupProps) => { // Component code goes here } The component receives input props defined by an ...

Numerous JSON entities

Curious to know if it's achievable to load more than one JSON file with just a single jQuery.ajax() call. Or do I have to make separate calls for each file? Warm regards, Smccullough ...

Is there a way to find keys with matching values within a dictionary?

In my dictionary, I have two sets of identical array values for different keys. My query is: How can I determine which keys have the same value based on inputting just one value? I want to retrieve all keys that share the same values as an output. This i ...

Ways to send a function from a parent component to a child in React

I have created a Dropdown component with a button that triggers the onClick event by calling a function named openDrop. Below is the code for the component: import React, { Component } from 'react' export default class Dropdown extends Componen ...

Error importing reach-router in Gatsbyjs causing website to break

While working on my Gatsby project, I decided to incorporate the React Cookie Consent package. However, upon installation and implementation attempt, my website crashed, displaying this error message: warn ./.cache/root.js Attempted import error: &a ...

Difficulty encountered when creating step definitions - Implementing Cucumber and Appium using JavaScript

I am currently embarking on a project that serves as more of a proof of concept. For me, this is a POC since I am aware that similar projects have been executed before. My focus revolves around working with Cucumber.js, Appium Server/Client, Node, and Jav ...

Collapsing or expanding the Material UI accordion may lead to flickering on the page

import React from "react"; import { makeStyles } from "@material-ui/core/styles"; import Accordion from "@material-ui/core/Accordion"; import AccordionDetails from "@material-ui/core/AccordionDetails"; import Accordi ...

Exploring the functionalities of React Hook userTracker within the Meteor framework

Attempting to set up Login/ Logout functionality using Meteor React hooks but encountering the following error. The login and logout functions are functioning correctly. Any idea what might be causing the issue with the current implementation? React vers ...

Is there a way to utilize code to invoke a method of an object? For example, calling MyObject.XVariable(//some function

I have a unique object that gets its data filled from an API call. let MyDog = { Name: 'Dog', } let arrayFunctions; fetchDogsFunctions(dogAPIUrl).then(res => { // The results variable contains an array of functions the dog can do, such as get ...

Tips for sending data to a router through props

In the file route.js, I have: import React from 'react' import { render } from 'react-dom' import {HashRouter ,Route,Link} from 'react-router-dom' const Router = (props) => ( <HashRouter> <div> < ...

I have successfully stored an array in session storage and was able to retrieve it. While I am able to access the data, I am unable to duplicate the array

let data=[ { "id":1, "name":"Dashboard", "status":0 }, { "id":2, "name":"Facility", "status":0 }] The above code snippet shows the original data. Next, I am storing this data using session storage as shown below--- $window.sessionStorage.setItem("userIte ...

Webpack 5 is failing to bundle re-exports correctly

Whilst bundling my web application, I've come across an issue with re-exports of certain modules not behaving as expected. Despite trying various optimization settings, I have been unsuccessful in resolving this issue. Setup Here's the setup tha ...