![]() ![]() This clearing of the canvas by the browser can be annoying, especially on mobile devices e.g. SignaturePad doesn't know about it by itself, so you can call signaturePad.clear() to make sure that signaturePad.isEmpty() returns correct value in this case. When you modify width or height of a canvas, it will be automatically cleared by the browser. ![]() You can also throttle the resize event - you can find some examples on this MDN page. Instead of resize event you can listen to screen orientation change, if you're using this library only on mobile devices. addEventListener ( "resize", resizeCanvas ) resizeCanvas ( ) fromData ( data ) // Draws signature image from an array of point groups, without clearing your existing image (clear defaults to true if not provided) signaturePad. ![]() toData ( ) // Draws signature image from an array of point groups signaturePad. fromDataURL ( "data:image/png base64,iVBORw0K." ) // Returns signature image as an array of point groups const data = signaturePad. Thus, after using #fromDataURL, #toData won't work properly. NOTE: This method does not populate internal data structure that represents drawn signature. toDataURL ( "image/svg+xml" ) // save image as SVG // Draws signature image from data URL. toDataURL ( "image/jpeg" ) // save image as JPEG signaturePad. toDataURL ( ) // save image as PNG signaturePad. querySelector ( "canvas" ) const signaturePad = new SignaturePad ( canvas ) // Returns signature image as data URL (see for the list of possible parameters) signaturePad.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |