Skip to content

Commit

Permalink
fix(scrollView): allow contenteditable element to be pressed normally
Browse files Browse the repository at this point in the history
Closes #421
  • Loading branch information
ajoslin committed Feb 17, 2014
1 parent a5d9647 commit 39ad3e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 6 additions & 0 deletions js/ext/angular/test/list.html
Expand Up @@ -92,6 +92,12 @@ <h1 class="title">List Tests</h1>

<content has-header="true">

<div contenteditable="true">
Hello!

Hello!
</div>

<list show-delete="isDeletingItems"
show-reorder="isReorderingItems"
on-refresh-holding="refreshHolding()"
Expand Down
22 changes: 10 additions & 12 deletions js/views/scrollView.js
@@ -1,3 +1,4 @@
var IS_INPUT_LIKE_REGEX = /input|textarea|select/i;
/*
* Scroller
* http://github.com/zynga/scroller
Expand Down Expand Up @@ -613,17 +614,19 @@ ionic.views.Scroll = ionic.views.View.inherit({
e.stopPropagation();
});

function shouldIgnorePress(e) {
// Don't react if initial down happens on a form element
return e.target.tagName.match(IS_INPUT_LIKE_REGEX) ||
e.target.isContentEditable;
}


if ('ontouchstart' in window) {

container.addEventListener("touchstart", function(e) {
if (e.defaultPrevented) {
return;
}
// Don't react if initial down happens on a form element
if (e.target.tagName.match(/input|textarea|select/i)) {
if (e.defaultPrevented || shouldIgnorePress(e)) {
return;
}

self.doTouchStart(e.touches, e.timeStamp);
e.preventDefault();
}, false);
Expand All @@ -644,14 +647,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
var mousedown = false;

container.addEventListener("mousedown", function(e) {
if (e.defaultPrevented) {
return;
}
// Don't react if initial down happens on a form element
if (e.target.tagName.match(/input|textarea|select/i)) {
if (e.defaultPrevented || shouldIgnorePress(e)) {
return;
}

self.doTouchStart([{
pageX: e.pageX,
pageY: e.pageY
Expand Down

0 comments on commit 39ad3e0

Please sign in to comment.