Skip to content

Commit

Permalink
fix(tap): ignoreScrollStart w/ data-tap-disabled
Browse files Browse the repository at this point in the history
If an element, or one of its ancestors, has the `data-tap-disabled`
attribute, then it should not start the scroll. Closes #1505
  • Loading branch information
Adam Bradley committed Jun 10, 2014
1 parent f5bb023 commit 772459d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion js/utils/gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@

// do a single tap
if(!did_doubletap || inst.options.tap_always) {
ionic.tap.cancelClick();
ionic.Gestures.detection.current.name = 'tap';
inst.trigger('tap', ev);
}
Expand Down
9 changes: 7 additions & 2 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ ionic.tap = {
(e.target.isContentEditable) ||
(/^(file|range)$/i).test(e.target.type) ||
(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-default')) == 'true' || // manually set within an elements attributes
(!!(/^(object|embed)$/i).test(e.target.tagName)); // flash/movie/object touches should not try to scroll
(!!(/^(object|embed)$/i).test(e.target.tagName)) || // flash/movie/object touches should not try to scroll
ionic.tap.isElementTapDisabled(e.target); // check if this element, or an ancestor, has `data-tap-disabled` attribute
},

isTextInput: function(ele) {
Expand Down Expand Up @@ -224,7 +225,11 @@ ionic.tap = {
if(!ele || ele.disabled || (/^(file|range)$/i).test(ele.type) || (/^(object|video)$/i).test(ele.tagName) ) {
return true;
}
if(ele.nodeType === 1) {
return ionic.tap.isElementTapDisabled(ele);
},

isElementTapDisabled: function(ele) {
if(ele && ele.nodeType === 1) {
var element = ele;
while(element) {
if( (element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true' ) {
Expand Down

0 comments on commit 772459d

Please sign in to comment.