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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -