Skip to content

Commit

Permalink
refactor(scrollView): use defaultPrevented
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Feb 12, 2014
1 parent 1437534 commit 4cba7aa
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions js/views/scrollView.js
Expand Up @@ -610,15 +610,15 @@ ionic.views.Scroll = ionic.views.View.inherit({
self.scrollTo(0, elementScrollTop + elementHeight - (deviceHeight * 0.5), true);
}

//Only the first scrollView parent of the element that broadcasted this event
//Only the first scrollView parent of the element that broadcasted this event
//(the active element that needs to be shown) should receive this event
e.stopPropagation();
});

if ('ontouchstart' in window) {

container.addEventListener("touchstart", function(e) {
if (e.__scroller) {
if (e.defaultPrevented) {
return;
}
// Don't react if initial down happens on a form element
Expand All @@ -628,8 +628,6 @@ ionic.views.Scroll = ionic.views.View.inherit({

self.doTouchStart(e.touches, e.timeStamp);
e.preventDefault();
//We don't want to stop propagation, other things might want to know about the touchstart
e.__scroller = true;
}, false);

document.addEventListener("touchmove", function(e) {
Expand All @@ -648,7 +646,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
var mousedown = false;

container.addEventListener("mousedown", function(e) {
if (e.__scroller) {
if (e.defaultPrevented) {
return;
}
// Don't react if initial down happens on a form element
Expand All @@ -661,8 +659,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
pageY: e.pageY
}], e.timeStamp);

//We don't want to stop propagation, other things might want to know about the touchstart
e.__scroller = true;
e.preventDefault();
mousedown = true;
}, false);

Expand Down

0 comments on commit 4cba7aa

Please sign in to comment.