Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Resizing Canvas #123

Open
pallavidhanopiya opened this issue Apr 13, 2018 · 1 comment
Open

Resizing Canvas #123

pallavidhanopiya opened this issue Apr 13, 2018 · 1 comment

Comments

@pallavidhanopiya
Copy link

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.

@JulyanoF
Copy link

JulyanoF commented Jul 8, 2019

My solution was this:

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants