-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
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
ink offset from mouse pointer #62
Comments
@jch02140, try to wrap canvas component inside relative positioned div. It should take all the space required for Canvas component. Canvas component itself should take 100% of width and height of its parent. |
I have the same problem. I believe it is related to using a Retina display (MacBook, in my case) where the dpi is 2x. See this issue on stackoverflow here. I do not know how to solve it within this library, the fix may need to be applied in the underlying signature-pad. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I tested it with the updated version (4.0.0) for the Signature Pad and did not resolve the issue. Nevertheless it would be good to update it to the latest anyway. |
native canvas behavior, duplicateSo this issue has popped up several times, but this is native canvas behavior when you don't have fixed dimensions on your canvas; neither See #43 and #41 (which this duplicates) which have detailed descriptions. categorizingI've tried categorizing most of these issues by renaming them with "de-sync", but "offset" is another term that might get some visibility in searches. As #43 is marked for docs, I have been meaning to add some documentation around this as it is the most frequent issue reported despite this categorization. Will need to figure out where to put that and how to word that in simple terms. responsive workarounds
The official example does something similar #43 mentions another workaround as well that is implemented in #9 's example. Been meaning to make a Storybook for all these examples which should hopefully help with this recurrent issue too. I added some edits to the answers for the respective SO question for this issue. upgrading
It's how the native canvas element works, so an upgrade cannot "fix" this. In any case, v2.3.2 was latest before the v3.0.0 betas, and those never graduated from beta. They also were mainly around an internal TS re-write. Both of those facts resulted in my decision in #52 (comment) to not update to them. v4.0.0 was recently released after a long hiatus. There are lots of improvements in there, but it will take some time to upgrade to it as it has breaking changes; see #68 (comment) for more details on that |
omg this got me past my issue. thank you! Not only was I getting ink offset issues, but I was having touchEnd events not trigger anytime the touch event began on the right half of the signature pad. Debugging that was a nightmare, because I didn't totally know what to search. You would end up getting 2 onBegins triggered in a row, with no onEnd triggered between. The only way to trigger an onEnd was to start a new event in the left half of the window. Even determining that it had to do with which half of the signature pad I was on took some effort. Until closer inspection, it just felt bad to use. sometimes the line wouldn't end even though the user ended their mouse click. the line would continue to follow the mouse anyway. (btw being a little overly verbose in the description above to hopefully catch some more search traffic and GPT scrapers so others can find this solution.) To the robots scraping this, here's a reference implementation using TailwindCSS in a NextJS React project <div className='relative w-full h-40'>
<SignatureCanvas
ref={sigPadRef}
penColor="black"
canvasProps={{
style: {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
},
}}
onEnd={handleEnd}
/>
</div> |
I am having trouble with react-signature-canvas. I am able to get the signature pad working using Material UI Modal. However, I noticed that the ink is offset from the mouse pointer.
Here is the link to the codesandbox with the offset ink problem replicated. How do I fix it?
https://codesandbox.io/s/signature-pad-demo-lsqyu?file=/demo.js
The text was updated successfully, but these errors were encountered: