demos/Collage/fabric.js
function (e, skipGroup) {

      var target,
          pointer = this.getPointer(e);

      // first check current group (if one exists)
      var activeGroup = this.getActiveGroup();

      if (activeGroup && !skipGroup && this.containsPoint(e, activeGroup)) {
        target = activeGroup;
        return target;
      }

      // then check all of the objects on canvas
      // Cache all targets where their bounding box contains point.
      var possibleTargets = [];
      for (var i = this._objects.length; i--; ) {
        if (this._objects[i] && this.containsPoint(e, this._objects[i])) {
          if (this.perPixelTargetFind || this._objects[i].perPixelTargetFind) {
            possibleTargets[possibleTargets.length] = this._objects[i];
          }
          else {
            target = this._objects[i];
            this.relatedTarget = target;
            break;
          }
        }
      }
      for (var i = 0, len = possibleTargets.length; i < len; i++) {
        var pointer = this.getPointer(e);
        var isTransparent = this._isTargetTransparent(possibleTargets[i], pointer.x, pointer.y);
        if (!isTransparent) {
          target = possibleTargets[i];
          this.relatedTarget = target;
          break;
        }
      }
      if (target && target.selectable) {
        return target;
      }
    }
function (e, skipGroup) {

      var target,
          pointer = this.getPointer(e);

      // first check current group (if one exists)
      var activeGroup = this.getActiveGroup();

      if (activeGroup && !skipGroup && this.containsPoint(e, activeGroup)) {
        target = activeGroup;
        return target;
      }

      // then check all of the objects on canvas
      // Cache all targets where their bounding box contains point.
      var possibleTargets = [];
      for (var i = this._objects.length; i--; ) {
        if (this._objects[i] && this.containsPoint(e, this._objects[i])) {
          if (this.perPixelTargetFind || this._objects[i].perPixelTargetFind) {
            possibleTargets[possibleTargets.length] = this._objects[i];
          }
          else {
            target = this._objects[i];
            this.relatedTarget = target;
            break;
          }
        }
      }
      for (var i = 0, len = possibleTargets.length; i < len; i++) {
        var pointer = this.getPointer(e);
        var isTransparent = this._isTargetTransparent(possibleTargets[i], pointer.x, pointer.y);
        if (!isTransparent) {
          target = possibleTargets[i];
          this.relatedTarget = target;
          break;
        }
      }
      if (target && target.selectable) {
        return target;
      }
    }
function ( e , skipGroup ) { var target , pointer = this . getPointer ( e ) ; // first check current group (if one exists) var activeGroup = this . getActiveGroup ( ) ; if ( activeGroup && ! skipGroup && this . containsPoint ( e , activeGroup ) ) { target = activeGroup ; return target ; } // then check all of the objects on canvas // Cache all targets where their bounding box contains point. var possibleTargets = [ ] ; for ( var i = this . _objects . length ; i -- ; ) { if ( this . _objects [ i ] && this . containsPoint ( e , this . _objects [ i ] ) ) { if ( this . perPixelTargetFind || this . _objects [ i ] . perPixelTargetFind ) { possibleTargets [ possibleTargets . length ] = this . _objects [ i ] ; } else { target = this . _objects [ i ] ; this . relatedTarget = target ; break ; } } } for ( var i = 0 , len = possibleTargets . length ; i < len ; i ++ ) { var pointer = this . getPointer ( e ) ; var isTransparent = this . _isTargetTransparent ( possibleTargets [ i ] , pointer . x , pointer . y ) ; if ( ! isTransparent ) { target = possibleTargets [ i ] ; this . relatedTarget = target ; break ; } } if ( target && target . selectable ) { return target ; } }
Method that determines what object we are clicking on
@method findTarget
@param {Event} e mouse event
@param {Boolean} skipGroup when true, group is skipped and only objects are traversed through
Method that determines what object we are clicking on