1 sc_require("views/view");
  2 
  3 SC.View.reopen(
  4   /** @scope SC.View.prototype */ {
  5 
  6   // ..........................................................
  7   // MULTITOUCH SUPPORT
  8   //
  9   /**
 10     Set to YES if you want to receive touch events for each distinct touch
 11     (rather than only the first touch start and last touch end).
 12   */
 13   acceptsMultitouch: NO,
 14 
 15   /**
 16     Is YES if the view is currently being touched. NO otherwise.
 17   */
 18   hasTouch: NO,
 19 
 20   /**
 21     A boundary set of distances outside which the touch will no longer be
 22     considered "inside" the view anymore.  This is useful when we want to allow
 23     a bit of touch drag outside of the view before we consider that the User's
 24     finger has completely left the view.  For example, a User might touch down
 25     on a button, but because of the wide surface of a finger, the touch might
 26     slip outside of the button's frame as the person lifts up.  If the button
 27     uses touchIsInBoundary it can make it easier for the User to hit it.
 28 
 29     By default, up to 25px on each side.
 30   */
 31   touchBoundary: { left: 25, right: 25, top: 25, bottom: 25 },
 32 
 33   /** @private
 34     A computed property based on frame.
 35   */
 36   _touchBoundaryFrame: function () {
 37     var boundary = this.get("touchBoundary"),
 38       ret;
 39 
 40     // Determine the frame of the View in screen coordinates
 41     ret = this.get("parentView").convertFrameToView(this.get('frame'), null);
 42 
 43     // Expand the frame to the acceptable boundary.
 44     ret.x -= boundary.left;
 45     ret.y -= boundary.top;
 46     ret.width += boundary.left + boundary.right;
 47     ret.height += boundary.top + boundary.bottom;
 48 
 49     return ret;
 50   }.property('touchBoundary', 'clippingFrame').cacheable(),
 51 
 52   /**
 53     Returns YES if the provided touch is within the boundary set by
 54     touchBoundary.
 55   */
 56   touchIsInBoundary: function(touch) {
 57     return SC.pointInRect({x: touch.pageX, y: touch.pageY},
 58       this.get("_touchBoundaryFrame"));
 59   }
 60 });
 61