title: how to override canvas.add() method in fabric js
body: <p>I am working in one image editor in which I want to add image into canvas with animation. 
  I try to override canvas.add() method but unable to play animation.</p>
  
  <p>I am using fabric js version 1.7.22.
  When i try to googling. I found one solution for add object with animation, but in that demo, they are make custom new method "fxadd()" for adding object.</p>
  
  <p>Here is the reference link : 
  <a href="https://github.com/fabricjs/fabric.js/issues/77" rel="nofollow noreferrer">https://github.com/fabricjs/fabric.js/issues/77</a></p>
  
  <p>But My code is too long and don't want to replace funciton name at all place.
  Is there any way to override existing fabric canvas.add() method then Please help me.</p>
  
  <pre><code>fabric.Canvas.prototype.add = (function(object, callback) {
    return function() {
      console.log('add into canvas', this);
      this.add(object); // here call self method which result in infinit loop
      object.animate('top', '100', {
        onChange: this.renderAll.bind(this),
        duration: 1000,
        easing: fabric.util.ease.easeOutElastic,
        onComplete: function() {}
      });
    };
  })(fabric.Canvas.prototype.add);
  
  var canvas = new fabric.Canvas('canvas1')
  var btn = document.getElementById('animate');
  
  btn.addEventListener('click', function() {
    canvas.clear();
    setTimeout(function() {
      run();
    }, 800);
  });
  var run = function() {
    var rect = new fabric.Rect({
      left: 50,
      top: 10,
      fill: 'red',
      width: 100,
      height: 100,
    });
  
    canvas.add(rect)
  }
  </code></pre>