szimek / signature_pad

HTML5 canvas based smooth signature drawing
http://szimek.github.io/signature_pad/
MIT License
10.92k stars 2.11k forks source link

Problem with signature on mobile site #692

Closed zaszekk closed 1 year ago

zaszekk commented 1 year ago

I don't know what im doing wrong but i can't repair that, its getting bouncy? I don't have name that behavior and its look like its not resized but i use that https://user-images.githubusercontent.com/79248956/216453467-fc42b124-980f-49c3-befa-892e782d708e.mp4

That was with computer view deselected And three is selected https://user-images.githubusercontent.com/79248956/216453722-05b6a1fc-68b9-4844-97c8-4b4ffe8306b7.mp4

zaszekk commented 1 year ago

and in first video its disappears that's my code :



> <div class="wrapper">

                                    <canvas id="signature-pad" class="signature-pad">
                                        <input id="file_input" type="hidden" name="sign_online">
                                            </canvas>
                                                </div>
                                                    </div>
                                                        <br>
                                                            <button id="clear">
                                                              Wyczyść
                                                                </button>
                                                                    <button type="submit" id ="save-png" class="submit" name="submit"  data-action="save-server">Potwierdź</button>
                                                                        </div>
        </form>                                                             
    </div>
        <script> 
            var canvas = document.getElementById('signature-pad');

            function resizeCanvas(){
                var ratio = Math.max(window.devicePixelRatio || 1,1);

                        canvas.width=canvas.offsetWidth * ratio;
                        canvas.height=canvas.offsetHeight * ratio;
                        canvas.getContext('2d').scale(ratio, ratio);
                }
                window.oneresize = resizeCanvas;
                resizeCanvas();

            var signaturePad= new SignaturePad(canvas,{backgroundColor:'rgb(192,192,192)'});
                document.getElementById('save-png').
                addEventListener('click',function(){
                    if(signaturePad.isEmpty()){
                        return alert("Prosze wprowadź najpierw podpis.");
                    }
                    else{
                        var dataURL=signaturePad.toDataURL();
                    }
                });
                document.getElementById('clear').
                addEventListener('click',function(){
                    signaturePad.clear();
                });```
zaszekk commented 1 year ago

and my css :

canvas {
  position: absolute;
  left: 0;
  top: 0;
  width:400px;
  height:200px;
  background-color: white;
}
.wrapper {
  position: relative;
  width: 400px;
  height: 200px;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
jricca218 commented 1 year ago

Did you fix this? I can reproduce this issue by adding width:100% to my custom css but when I just leave the width and height attributes as is, it works fine. However, leaving it as is makes it not be responsive and that is what I need

zaszekk commented 1 year ago

I must check that

UziTech commented 1 year ago

closing as stale