Skip to content

Commit

Permalink
fix(scroll): remove isContentEditable from ignoreScrollStart
Browse files Browse the repository at this point in the history
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
  • Loading branch information
adamdbradley committed Aug 30, 2014
1 parent df57858 commit caf1272
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/angular/controller/sideMenuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/angular/directive/sideMenu.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions test/unit/utils/tap.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
Expand Down

0 comments on commit caf1272

Please sign in to comment.