brinley / jSignature

jQuery plugin for adding web signature functionality
http://www.unbolt.net/jSignature
696 stars 529 forks source link

wrong size when used in a non active bootstrap tab #31

Closed andreabalducci closed 11 years ago

andreabalducci commented 11 years ago

The signature canvas has wrong size when the jSignature is called on a non visible tab.

http://jsfiddle.net/gD8QC/

dvdotsenko commented 11 years ago

Technically the canvas is of exactly the right size. jSignature adapts to the size of the parent div. What's wrong size is the hidden tab, likely to be 0x0 in size while it's hidden.

What I would suggest is to show the tab first, and, then, init the signature against it. This way, by the time jSignature is about to be created, the tab will have the right size.

http://stackoverflow.com/questions/11329405/twitter-bootstrap-attach-action-on-tab-when-initialized

andreabalducci commented 11 years ago

the tab is binded with angular-bootstrap and I've a directive for the signature. As a workaround I managed to fix the issue triggering a resize event to the parentdiv with jquery on tab activation $('#signatureparent').resize();

tomyam1 commented 11 years ago

I just had the same problem. The $('#signatureparent').resize(); solution didn't work (caused some problems with getData and setData)

My solution was just to set the width/height when initializing, e.g.: $("#signatureparent").jSignature({width:100});