demos/Collage/fabric.js
function (object, callbacks) {
    callbacks = callbacks || { };

    var empty = function() { },
        onComplete = callbacks.onComplete || empty,
        onChange = callbacks.onChange || empty,
        _this = this;

    fabric.util.animate({
      startValue: object.get('left'),
      endValue: this.getCenter().left,
      duration: this.FX_DURATION,
      onChange: function(value) {
        object.set('left', value);
        _this.renderAll();
        onChange();
      },
      onComplete: function() {
        object.setCoords();
        onComplete();
      }
    });

    return this;
  }
function (object, callbacks) {
    callbacks = callbacks || { };

    var empty = function() { },
        onComplete = callbacks.onComplete || empty,
        onChange = callbacks.onChange || empty,
        _this = this;

    fabric.util.animate({
      startValue: object.get('left'),
      endValue: this.getCenter().left,
      duration: this.FX_DURATION,
      onChange: function(value) {
        object.set('left', value);
        _this.renderAll();
        onChange();
      },
      onComplete: function() {
        object.setCoords();
        onComplete();
      }
    });

    return this;
  }
function ( object , callbacks ) { callbacks = callbacks || { } ; var empty = function ( ) { } , onComplete = callbacks . onComplete || empty , onChange = callbacks . onChange || empty , _this = this ; fabric . util . animate ( { startValue : object . get ( 'left' ) , endValue : this . getCenter ( ) . left , duration : this . FX_DURATION , onChange : function ( value ) { object . set ( 'left' , value ) ; _this . renderAll ( ) ; onChange ( ) ; } , onComplete : function ( ) { object . setCoords ( ) ; onComplete ( ) ; } } ) ; return this ; }
Centers object horizontally with animation.
@method fxCenterObjectH
@param {fabric.Object} object Object to center
@param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
@return {fabric.Canvas} thisArg
@chainable
Centers object horizontally with animation .