legalthings / angular-signature

HTML5 canvas based smooth signature drawing as angularJS directive (http://szimek.github.io/signature_pad/)
MIT License
105 stars 91 forks source link

Canvas has no height #42

Closed mcblum closed 7 years ago

mcblum commented 7 years ago

So I finally figured how what our issue is, sorry to keep bugging you about it:

screen shot 2016-11-17 at 9 05 29 pm
mcblum commented 7 years ago

Is there anything we can do to force the canvas element to expand?

mcblum commented 7 years ago

Ok, so I did get this to work. I modified the directive to wrap the onResize function in a 600ms $timeout. Also, I set the width and the height of the canvas to the width and the height of the parent element. Should I submit a PR or is this not exactly how you want it to work?

ghost commented 7 years ago

can you show your onResize code - I am getting same issue and it really buggin me :)

jasny commented 7 years ago

@mcblum This looks like an old issue. Did you try the master branch?

adrogon commented 7 years ago

Agreed it is an old issue, but you will keep having this question until a new release is provided :)

mcblum commented 7 years ago

@jasny I did! I pushed the project with the most recent version (master branch) and the issue actually got worse.

@hplloyd here's what I did to the scope.onResize function:

scope.onResize = function () {
                    $timeout(function () {
                        var canvas = element.find('canvas')[0];
                        canvas.width = element[0].offsetWidth;
                        canvas.height = element[0].offsetHeight;
                    }, 600);
                };

I'm not sure if this has other consequences, I know I removed the code which compensated for pixel density but I didn't care as much if the signature looked a little blurry just as long as people could sign.

jasny commented 7 years ago

Released v1.0.0. Considering this solved.

@mcblum If you still have an issue with v1.0, please create a jsfiddle that demonstrates it.