I have a HTML5 Canvas object, which I resize using Javascript. I then draw on it.
On iOS, the drawing doesn't show unless I delay the drawing with setTimeout.
So this code shows nothing...
myCanvas.width = width;
myContext.strokeStyle = '#000';
myContext.moveTo(0, 0);
myContext.lineTo(2000, 2000);
myContext.stroke();
...but this does:
myCanvas.width = width;
setTimeout(function(){
myContext.strokeStyle = '#000';
myContext.moveTo(0, 0);
myContext.lineTo(2000, 2000);
myContext.stroke();
}, 100);
Both work fine on desktop browsers, but not in Safari iOS.
What's causing this and is setTimeout the best solution to get around it?
Thanks,