ghost-cursor icon indicating copy to clipboard operation
ghost-cursor copied to clipboard

Problem with rounded buttons

Open marcusdiy opened this issue 8 months ago • 6 comments

When the button is a circle or has rounded box the click may happen to be outside the button. There is needed a better solution to handle rounded shapes otherwise clicks wont work.

marcusdiy avatar Oct 17 '23 13:10 marcusdiy

Can you share the example from a webpage or component?

captainjackrana avatar Oct 30 '23 17:10 captainjackrana

Sure. Just create a round button and try to click it.

    const GhostCursor = require("ghost-cursor");
    const puppeteer = require("puppeteer");
    (async () => {

      const browser = await puppeteer.launch({ headless: false });
      const page = await browser.newPage()
      const cursor = GhostCursor.createCursor(page);
      await GhostCursor.installMouseHelper(page);
      //await page.goto('https://example.com/');
      await page.reload();

      await page.evaluate(() => {
        let h = `
          <div id="missedCount">Missed count: <b>0</b></div>
          <div id="btn">Click me</div>
          <style> #btn {border-radius: 93% 7% 96% 4% / 93% 6% 94% 7%; padding: 30px; background: #ffdcdc} </style>`;
        let s = document.createElement('div'); s.innerHTML = h; document.body.appendChild(s);
      });

      await page.evaluate(() => {
        let h = `
          let missed = 0;
          document.body.addEventListener('click', () => { missed++; updateCount(); });
          document.querySelector('#btn').addEventListener('click', (e) => { e.stopImmediatePropagation(); });
          function updateCount() { document.querySelector('#missedCount b').innerText = missed; }`;
        let s = document.createElement('script'); s.innerHTML = h; document.body.appendChild(s);
      });
      while (true) {
        let $btn = await page.$('#btn');
        await cursor.click($btn).catch(console.error);
      }

    })();

marcusdiy avatar Jan 04 '24 17:01 marcusdiy

A solution could be checking if the element hovered is actually our target, and if not retry. document.elementFromPoint(e.clientX, e.clientY)

marcusdiy avatar Jan 04 '24 20:01 marcusdiy

also having this issue

simonadler1 avatar Mar 22 '24 20:03 simonadler1

same

viniciuspatzer avatar Mar 24 '24 02:03 viniciuspatzer

same issue

manishiitg avatar Apr 13 '24 15:04 manishiitg

Any update on this issue? Facing same challenge

revic1993 avatar Apr 19 '24 12:04 revic1993