demos/Collage/fabric.js
function (object) {
      var idx = this._objects.indexOf(object),
          nextIntersectingIdx = idx;

      // if object is not on the bottom of stack
      if (idx !== 0) {

        // traverse down the stack looking for the nearest intersecting object
        for (var i=idx-1; i>=0; --i) {
          if (object.intersectsWithObject(this._objects[i]) || object.isContainedWithinObject(this._objects[i])) {
            nextIntersectingIdx = i;
            break;
          }
        }
        removeFromArray(this._objects, object);
        this._objects.splice(nextIntersectingIdx, 0, object);
      }
      return this.renderAll();
    }
function (object) {
      var idx = this._objects.indexOf(object),
          nextIntersectingIdx = idx;

      // if object is not on the bottom of stack
      if (idx !== 0) {

        // traverse down the stack looking for the nearest intersecting object
        for (var i=idx-1; i>=0; --i) {
          if (object.intersectsWithObject(this._objects[i]) || object.isContainedWithinObject(this._objects[i])) {
            nextIntersectingIdx = i;
            break;
          }
        }
        removeFromArray(this._objects, object);
        this._objects.splice(nextIntersectingIdx, 0, object);
      }
      return this.renderAll();
    }
function ( object ) { var idx = this . _objects . indexOf ( object ) , nextIntersectingIdx = idx ; // if object is not on the bottom of stack if ( idx !== 0 ) { // traverse down the stack looking for the nearest intersecting object for ( var i = idx - 1 ; i >= 0 ; -- i ) { if ( object . intersectsWithObject ( this . _objects [ i ] ) || object . isContainedWithinObject ( this . _objects [ i ] ) ) { nextIntersectingIdx = i ; break ; } } removeFromArray ( this . _objects , object ) ; this . _objects . splice ( nextIntersectingIdx , 0 , object ) ; } return this . renderAll ( ) ; }
Moves an object one level down in stack of drawn objects
@method sendBackwards
@param object {fabric.Object} Object to send
@return {fabric.Canvas} thisArg
@chainable
Moves an object one level down in stack of drawn objects