Sha256: 07c7faf59e51935b492f91b9d83e96f19872dfc596dfbb093ebd622586286d4d

Contents?: true

Size: 1.6 KB

Versions: 31

Compression:

Stored size: 1.6 KB

Contents

sc_require("views/view");

SC.View.reopen(
  /** @scope SC.View.prototype */ {

  // ..........................................................
  // MULTITOUCH SUPPORT
  //
  /**
    Set to YES if you want to receive touch events for each distinct touch (rather than only
    the first touch start and last touch end).
  */
  acceptsMultitouch: NO,

  /**
    Is YES if the view is currently being touched. NO otherwise.
  */
  hasTouch: NO,

  /**
    A boundary set of distances outside which the touch will not be considered "inside" the view anymore.

    By default, up to 50px on each side.
  */
  touchBoundary: { left: 50, right: 50, top: 50, bottom: 50 },

  /**
    @private
    A computed property based on frame.
  */
  _touchBoundaryFrame: function (){
    return this.get("parentView").convertFrameToView(this.get('frame'), null);
  }.property("frame", "parentView").cacheable(),

  /**
    Returns YES if the provided touch is within the boundary.
  */
  touchIsInBoundary: function(touch) {
    var f = this.get("_touchBoundaryFrame"), maxX = 0, maxY = 0, boundary = this.get("touchBoundary");
    var x = touch.pageX, y = touch.pageY;

    if (x < f.x) {
      x = f.x - x;
      maxX = boundary.left;
    } else if (x > f.x + f.width) {
      x = x - (f.x + f.width);
      maxX = boundary.right;
    } else {
      x = 0;
      maxX = 1;
    }

    if (y < f.y) {
      y = f.y - y;
      maxY = boundary.top;
    } else if (y > f.y + f.height) {
      y = y - (f.y + f.height);
      maxY = boundary.bottom;
    } else {
      y = 0;
      maxY = 1;
    }

    if (x > 100 || y > 100) return NO;
    return YES;
  }
});

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.1 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0-java lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.rc.2-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.rc.2 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.rc.2-java lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.rc.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.rc.1 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.rc.1-java lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.beta.3-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.beta.3-java lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.beta.3 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js
sproutcore-1.6.0.beta.2-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js