![]() ![]() ![]() you can lock screen orientation, or read an image from the canvas before resizing it and write the image back after. 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 omData(signaturePad.toData()) to reset the drawing, or 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 ( ) toDataURL ( "image/svg+xml" ) // save image as SVG data url // Return svg string without converting to base64 signaturePad. toDataURL ( "image/jpeg", 0.5 ) // save image as JPEG with 0.5 image quality signaturePad. 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 |