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


      // if object is not on top of stack (last item in an array)
      if (idx !== objects.length-1) {

        // traverse up the stack looking for the nearest intersecting object
        for (var i = idx + 1, l = this._objects.length; i < l; ++i) {
          if (object.intersectsWithObject(objects[i]) || object.isContainedWithinObject(this._objects[i])) {
            nextIntersectingIdx = i;
            break;
          }
        }
        removeFromArray(objects, object);
        objects.splice(nextIntersectingIdx, 0, object);
      }
      this.renderAll();
    }
function (object) {
      var objects = this.getObjects(),
          idx = objects.indexOf(object),
          nextIntersectingIdx = idx;


      // if object is not on top of stack (last item in an array)
      if (idx !== objects.length-1) {

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