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

213
Views
Why is the cursor shaking?

My marker has a problem that when I do mouse:hover the cursor is shaking.

I put my component into codesandbox with the same code I'm using on my application.

You may notice when you bring the mouse closer to the edge of the marker, the cursor starts to shaking.

.marker {
  transition: all 0.5s ease;
  border: 2px solid #fff;
  background-color: #61ba9e;
  border-radius: 100%;
  width: 20px;
  height: 20px;
}

.marker:hover {
  height: 12.5px;
  width: 12.5px;
  box-shadow: 0 0 0 4px rgb(97 186 158 / 60%);
  cursor: pointer;
}
<div class="marker"></div>

I don't know why this is happening, can you help me?

Thanks in advance.

enter image description here

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

0

The shaking is caused by your element shrinking and therefore your cursor not hovering anymore (and then re-growing as you aren't hovering, causing your cursor to change again)

Instead of changing the size of your marker, why not use a pseudo element, then your hand won't "shake" as it will always hover the marker (but the pseudo element will change size instead).

.marker {
  width: 20px;
  height: 20px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.marker:hover {
  cursor: pointer;
}

.marker:after {
  content: '';
  display: block;
  transition: all 0.5s ease;
  border: 2px solid #fff;
  background-color: #61ba9e;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  box-sizing:border-box;
}

.marker:hover:after {
  height: 12.5px;
  width: 12.5px;
  box-shadow: 0 0 0 4px rgb(97 186 158 / 60%);
}
<div class="marker"></div>

about 4 years ago · Juan Pablo Isaza Report

0

It's shaking because your object is originally 20x20 pixels in size. Once it your mouse :hover's it shrinks in size.

Since the cursor is not perfectly centered on the object it reaches a point where the mouse is out of the bounding box of your element, which restores it's original width... which then makes it bigger and the mouse it's again inside the bounding box...

You see where this is going right? We have an infinite loop of shrinking and growing the element's bounding box.

A trick for getting around this may be to provide a wrapper that stays in size 20x20 and have the marker respond to the wrapper being :hover'ed

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!