We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It doesn't work
Work
html
<svg viewBox="0 0 1356 678" xmlns="http://www.w3.org/2000/svg" id="test"> <path id="check" fill="#ffffff" stroke="#000000" d="M 369.884 206.316 C 369.891 206.316 442.308 206.316 442.315 206.316 C 442.315 206.336 442.315 404.933 442.315 404.952 C 442.308 404.952 369.891 404.952 369.884 404.952 C 369.884 404.933 369.884 206.336 369.884 206.316 Z"/> <circle id="ind" r="25" cx="70" cy="70" stroke="none" fill="#ff0000" /> <circle id="cursor" r="2" cx="70" cy="70" stroke="none" fill="#000000" /> </svg>
js
document.querySelector("#test").onclick = function(event) { let d = document.querySelector("#check").getAttribute("d"); let check = pointInSvgPath(d, event.pageX, event.pageY); document.querySelector("#cursor").setAttribute("cx", event.pageX); document.querySelector("#cursor").setAttribute("cy", event.pageY); if (check) { document.querySelector("#ind").setAttribute("fill", "#00ff00"); } else { document.querySelector("#ind").setAttribute("fill", "#ff0000"); } }
Actually I found a solution, I replaced .toFixed(2) with .toFixed(1) and it started detecting correctly.
.toFixed(2)
.toFixed(1)
P.s On more complex ones, the problem is not solved.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It doesn't work
Work
html
js
Actually I found a solution, I replaced
.toFixed(2)
with.toFixed(1)
and it started detecting correctly.P.s On more complex ones, the problem is not solved.
The text was updated successfully, but these errors were encountered: