wPaint
wPaint copied to clipboard
Resizing Canvas
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.
My solution was this:
$(window).on('resize', function(){
setTimeout(() => {
if($('#wPaint').length){
$("#wPaint").wPaint('resize');
}
}, 350);
});