html5 - Determine when a canvas is resized -
i trying determine when canvas
resized repaint it.
context: canvas
inserted in flex layout , height gets set flexbox model , changes depending on other layout elements content , size may dynamically vary (e.g., result of ajax request inserts texts in nearby span, causes canvas
grow by, say, 10 pixels vertically).
it seems resize
event sent window — resize event not trick here, canvas may change size when window not.
how can notified when canvas
resized?
if multiple parts of code change canvas size, must indeed refactor each scriptlet notify when changes canvas size.
an easy way create resizing function scriptlet must use resize canvas. if function called, know scriptlet has resized canvas:
function resizecanvas(canvas,w,h){ canvas.width=w; canvas.height=h; // canvas resizing flow point // respond resizing here. console.log('the canvas has been resized'); }
Comments
Post a Comment