Skip to content

Commit

Permalink
fix(scrollView): nested scrollViews now work independently
Browse files Browse the repository at this point in the history
Closes #278
  • Loading branch information
ajoslin committed Feb 10, 2014
1 parent 38c756b commit 4cc4a18
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
41 changes: 41 additions & 0 deletions js/ext/angular/test/nestedScroll.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html ng-app="ionic">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>

<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<link rel="stylesheet" href="../../../../dist/css/ionic.css" />
<script src="../../../../dist/js/ionic.js"></script>
<script src="../../../../dist/js/angular/angular.js"></script>
<script src="../../../../dist/js/angular/angular-animate.js"></script>
<script src="../../../../dist/js/angular/angular-sanitize.js"></script>
<script src="../../../../dist/js/angular-ui/angular-ui-router.js"></script>
<script src="../../../../dist/js/ionic-angular.js"></script>

</head>

<body>

<div ng-controller="Ctrl">
<header-bar title="title" type="bar-positive">
</header-bar>
<content has-header="true" style="background: lightblue;">
<h1>outer</h1>
<scroll style="background: lightgreen; height: 200px;">
<h1>inner</h1>
<p ng-repeat="i in range">{{i}}</p>
</scroll>
<p ng-repeat="i in range">{{i}}</p>
</content>
</div>
<script>
function Ctrl($scope) {
$scope.range = [];
for (var i=0; i<20; i++) {
$scope.range.push(i);
}
}
</script>
</body>
</html>
10 changes: 10 additions & 0 deletions js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,18 @@ ionic.views.Scroll = ionic.views.View.inherit({
if ('ontouchstart' in window) {

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

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 @@ -621,6 +626,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
var mousedown = false;

container.addEventListener("mousedown", function(e) {
if (e.__scroller) {
return;
}
// Don't react if initial down happens on a form element
if (e.target.tagName.match(/input|textarea|select/i)) {
return;
Expand All @@ -631,6 +639,8 @@ 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;
mousedown = true;
}, false);

Expand Down

0 comments on commit 4cc4a18

Please sign in to comment.