title: How to make width and height of a rectangle updates after resize in fabric js?
body: <p>I want to contain the rectangles within the image and wrote the following code. It does not work after resize because the width and height of the active object doesn't seem to update after resize.</p>
  
  <p>This is the jsfiddle: <a href="https://jsfiddle.net/yxchng/0hL2khro/191/" rel="nofollow noreferrer">https://jsfiddle.net/yxchng/0hL2khro/191/</a></p>
  
  <pre><code>canvas.on("object:moving", function(opt) {
      activeObject = canvas.getActiveObject()
    if (activeObject.left &lt; 0) {
      activeObject.left = 0;
    }
    if (activeObject.top &lt; 0) {
      activeObject.top = 0;
    }
    if (activeObject.left + activeObject.width &gt; 1000) {
      activeObject.left = 1000 - activeObject.width;
    }
    if (activeObject.top + activeObject.height &gt; 1000) {
      activeObject.top = 1000 - activeObject.height;
    }
    activeObject.setCoords();
  });
  </code></pre>
  
  <p>Is there a better way to contain objects within image? </p>