Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Is there a way to change default action of a sensitive area in button?

I wrote a calculator App in React and generally, it's ok, but...

If I hold it longer I notice that the click is confirmed if click-down had been on the button and click-up have been on the button

I know that margin is not clickable, but in this App I can't use, for example, position

The point is that the button is animated and when click-up, cursor is not over the button. And I have a question that is there a way to prevent the whole problem in any way, so that it works the way it should?

Here's the link to the repo: https://github.com/FloweDewolf/calculator

Here's the link to the calculator: https://flowedewolf.github.io/calculator

And thanks for every help!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One solution here would be to use a pseudo-element for the styling. This way the actual button bounds (red border) will stay in place. It also prevents writing additional logic to solve a styling issue.

let count = 0;
function handleClick() {
  document.getElementById('counter').innerHTML = ++count;
}
button {
  position: relative;
  background: transparent;
  width: 5rem;
  height: 5rem;
  border: 1px solid red;
  z-index: 1;
}

button::before {
 position: absolute;
 content: ' ';
 left: 0;
 top: 0;
 height: 4rem;
 width: 4rem;
 background: #ff9999;
 z-index: -1;
}
button:active::before {
 left: 1rem;
 top: 1rem;
}
<button type="button" onclick="handleClick()">Add 1</button>

<p>current count: <span id="counter">0</span></p>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!