fix(scroll): remove isContentEditable from ignoreScrollStart

If an element isContentEditable, do not ignoreScrollStart incase users
are using contenteditable elements to scroll. This may have originally
been put in because it disabled text selection, and moving the text
cursor on touch. But this doesn’t seem to be the case anymore, so it
may have been put in for platform versions we no longer support. Also
fix the data-prevent-scroll dataset attribute. Closes #2091
This commit is contained in:
Adam Bradley
2014-08-29 23:35:07 -05:00
parent df57858521
commit caf1272186
4 changed files with 5 additions and 6 deletions

View File

@@ -348,7 +348,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
!e.gesture.srcEvent.defaultPrevented &&
!e.target.tagName.match(/input|textarea|select|object|embed/i) &&
!e.target.isContentEditable &&
!(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-default') == 'true');
!(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-scroll') == 'true');
};
$scope.sideMenuContentTranslateX = 0;

View File

@@ -152,9 +152,8 @@ ionic.tap = {
ignoreScrollStart: function(e) {
return (e.defaultPrevented) || // defaultPrevented has been assigned by another component handling the event
(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
(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-scroll')) == 'true' || // manually set within an elements attributes
(!!(/^(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
},

View File

@@ -159,7 +159,7 @@ describe('Ionic Angular Side Menu', function() {
e.target.dataset = undefined;
e.target.getAttribute = function(val){
return (val == 'data-prevent-default' ? 'true' : undefined);
return (val == 'data-prevent-scroll' ? 'true' : undefined);
};
expect(ctrl.isDraggableTarget(e)).toBe(false);

View File

@@ -1129,11 +1129,11 @@ describe('Ionic Tap', function() {
expect( ionic.tap.ignoreScrollStart(e) ).toEqual(true);
});
it('Should prevent scrolling if the browser doesnt support dataset but target has data-prevent-default attribute', function() {
it('Should prevent scrolling if the browser doesnt support dataset but target has data-prevent-scroll attribute', function() {
var target = {
tagName: 'div',
getAttribute: function(val) {
if(val === 'data-prevent-default') {
if(val === 'data-prevent-scroll') {
return 'true';
}
}