title: how to restrict rectangle resizing/moving outside a image in fabricjs?
body: <p>I am using fabricjs and trying to restrict moving/resizing of rectangles outside image.</p>
  
  <p>Here's the fiddle of what I have so far: <a href="http://jsfiddle.net/Subhasish2015/h2zvj3un/1/" rel="nofollow">Fiddle</a></p>
  
  <p>Code: </p>
  
  <pre><code>var canvas = new fabric.Canvas('c');
  
  canvas.add(new fabric.Circle({ radius: 30, fill: '#f55', top: 100, left: 100 }));
  canvas.setBackgroundImage('http://www.beatnyama.com/wp-content/uploads/2015/05/assets.jpg', canvas.renderAll.bind(canvas));
  
  this.__canvases.push(canvas);  
  
  canvas.observe("object:moving", function(e){
      var obj = e.target;
      //code goes here to restrict moving/resizing outside image
  });
  </code></pre>
  
  <p>How can I implement this?</p>