From 49c9db9c49cbf06a0cbaa9ebf8b5f855761812fb Mon Sep 17 00:00:00 2001 From: Kin Blas Date: Thu, 16 Dec 2010 11:04:48 -0800 Subject: [PATCH] Turning on delayedClick by default. Added triggers for mousedown and mouse up in the delayed case because some of hte jqm components register handlers on those events to set the component states. Note that the focus() trigger is commented out temporarily. It seems to cause the content within the scrollview clip to scroll to the point where item being focused sits in the flow .. unfortunately this screws up the rendering because we are using CSS3 translate, so the item clicked on is out of view. Modified sv-test-02.html so that the clone event sets the target property on the fake event. --- experiments/scrollview/jquery.mobile.scrollview.js | 13 +++++++++---- experiments/scrollview/sv-test-02.html | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/experiments/scrollview/jquery.mobile.scrollview.js b/experiments/scrollview/jquery.mobile.scrollview.js index 7dd7b17d..df465fe4 100644 --- a/experiments/scrollview/jquery.mobile.scrollview.js +++ b/experiments/scrollview/jquery.mobile.scrollview.js @@ -30,7 +30,7 @@ jQuery.widget( "mobile.scrollview", jQuery.mobile.widget, { pagingEnabled: false, delayedClickSelector: "a,input,textarea,select,button,.ui-btn", - delayedClickEnabled: false + delayedClickEnabled: true }, _makePositioned: function($ele) @@ -284,8 +284,9 @@ jQuery.widget( "mobile.scrollview", jQuery.mobile.widget, { var c = this._$clip; var v = this._$view; - if (this.options.delayedClickEnabled) + if (this.options.delayedClickEnabled) { this._$clickEle = $(e.target).closest(this.options.delayedClickSelector); + } this._lastX = ex; this._lastY = ey; this._doSnapBackX = false; @@ -512,8 +513,12 @@ jQuery.widget( "mobile.scrollview", jQuery.mobile.widget, { this._disableTracking(); - if (this.options.delayedClickEnabled && !this._didDrag) { - this._$clickEle.click(); + if (!this._didDrag && this.options.delayedClickEnabled && this._$clickEle.length) { + this._$clickEle + .trigger("mousedown") + //.trigger("focus") + .trigger("mouseup") + .trigger("click"); } // If a view scrolled, then we need to absorb diff --git a/experiments/scrollview/sv-test-02.html b/experiments/scrollview/sv-test-02.html index 470835a1..4d70d845 100644 --- a/experiments/scrollview/sv-test-02.html +++ b/experiments/scrollview/sv-test-02.html @@ -81,7 +81,7 @@ var hu = $.mobile.scrollview.prototype._handleDragStop; function getDummyEvent(o) { - return { _pd: false, _sp: false, preventDefault: function(){ this._pd = true; }, stopPropagation: function(){ this._sp = true; }}; + return { target: o.target, _pd: false, _sp: false, preventDefault: function(){ this._pd = true; }, stopPropagation: function(){ this._sp = true; }}; } function updateEvent(e, cb_pd, cb_sp)