1
0
mirror of synced 2024-11-22 13:06:08 +03:00

Merge pull request #2096 from springboardretail/mobile-fixes

make selection on iOS more intuitive
This commit is contained in:
Kevin Brown 2014-03-21 20:36:40 -04:00
commit 2752563c80

View File

@ -736,6 +736,9 @@ the specific language governing permissions and limitations under the Apache Lic
installFilteredMouseMove(this.results);
this.dropdown.on("mousemove-filtered touchstart touchmove touchend", resultsSelector, this.bind(this.highlightUnderEvent));
this.dropdown.on("touchend", resultsSelector, this.bind(this.selectHighlighted));
this.dropdown.on("touchmove", resultsSelector, this.bind(this.touchMoved));
this.dropdown.on("touchstart touchend", resultsSelector, this.bind(this.clearTouchMoved));
installDebouncedScroll(80, this.results);
this.dropdown.on("scroll-debounced", resultsSelector, this.bind(this.loadMoreIfNeeded));
@ -1523,6 +1526,14 @@ the specific language governing permissions and limitations under the Apache Lic
this.results.find(".select2-highlighted").removeClass("select2-highlighted");
},
touchMoved: function() {
this._touchMoved = true;
},
clearTouchMoved: function() {
this._touchMoved = false;
},
// abstract
countSelectableResults: function() {
return this.findHighlightableChoices().length;
@ -1761,6 +1772,10 @@ the specific language governing permissions and limitations under the Apache Lic
// abstract
selectHighlighted: function (options) {
if (this._touchMoved) {
this.clearTouchMoved();
return;
}
var index=this.highlight(),
highlighted=this.results.find(".select2-highlighted"),
data = highlighted.closest('.select2-result').data("select2-data");