wPaint icon indicating copy to clipboard operation
wPaint copied to clipboard

Resizing Canvas

Open pallavidhanopiya opened this issue 7 years ago • 1 comments

Hello, I'm trying to resize my canvas on change of device orientation in mobile web view. I'm using the below code: $(window).resize(function () { $('#wPaint_181_17').css({ width: $(window).width(), height: $(window).height()
}); });

In my canvas area i have any image and I draw something on it, it's working fine. I change orientation of device and call method to resize canvas, it works image is resized. But now when i'm using any canvas tool to draw on image , then the coordinates are shifting. If i'm drawing on left area then it's viewed shifted towards more right.

If I reload my page then it works fine, but I can't reload the page because I have some other data entered by user on the page and also previous changes done in Canvas image which I need to store on change of device orientation. Please suggest some solution.

pallavidhanopiya avatar Apr 13 '18 09:04 pallavidhanopiya

My solution was this:

$(window).on('resize', function(){
    setTimeout(() => {
      if($('#wPaint').length){
        $("#wPaint").wPaint('resize');
      }
    }, 350);
  });

JulyanoF avatar Jul 08 '19 18:07 JulyanoF