Note that there are some explanatory texts on larger screens.

plurals
  1. POiPad HTML5 canvas not refreshing
    primarykey
    data
    text
    <p><strong>Edit: Demo Code is found in the "parallelogram explorer" tab here: <a href="http://atmdev01.procloud.net/geometry_tools9/" rel="nofollow">http://atmdev01.procloud.net/geometry_tools9/</a></strong></p> <p>So I'm calling the following javascript function at document load to draw the perimeter of a parallelogram, and it is working just fine to do that. The issue is when I call the function from the touchmove handler to allow an iPad user to adjust the size of the parallelogram, the canvas is not properly redrawing the shape. In fact it is not responding at all. I've run some alerts to verify that this function is actually being run and it is. </p> <p>Could it be an issue with the way I'm clearing the canvas (the "canvas.width = canvas.width + 0" method) or simply with refresh rates on the iPad?</p> <p>The interesting part is that it's working perfectly in a desktop browser using mousemove, but not on an iPad using touchmove. Please advise...</p> <p>(the "corners" in the code are the areas where the user can touch and drag to resize the parallelogram)</p> <pre><code>this.drawSides = function() { var order = [1, 2, 4, 3]; var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); var firstCorner = this.getCornerObj(1); var secondCorner = this.getCornerObj(2); var firstCornerOpp = this.getCornerObj(firstCorner.opp); var secondCornerOpp = this.getCornerObj(secondCorner.opp); /* Clear the canvas and draw a parallelogram with the provided corners */ canvas.width = canvas.width + 0; //clears the canvas faster than clearRect ctx.beginPath(); for (i in order) { if (i &lt; order.length) { var cornerObj = this.getCornerObj(order[i]); if (order[i] &gt; 1) { var prevObj = this.getCornerObj(order[i-1]); ctx.moveTo(prevObj.x + (prevObj.width)/2, prevObj.y + (prevObj.height)/2); ctx.lineTo(cornerObj.x + (cornerObj.width)/2, cornerObj.y + (cornerObj.height)/2); } } } ctx.lineTo(firstCorner.x + (firstCorner.width)/2, firstCorner.y + (firstCorner.height)/2); ctx.strokeStyle = "#300"; ctx.stroke(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload