I have two ion-scroll
elements on my page, the top one scrolls horizontally, below it is a list that should scroll vertically.
The problem is it doesn't. It just bounces back to the top of the list.
Example: http://codepen.io/CaffGeek/pen/LEVdVY
I have found that if I set a height on the vertical ion-scroll it 'works' but this needs to work on multiple devices and I don't know what height to use. I'd prefer to not have to watch events, and recalculate the height each time. Anybody know how to fix this?
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Ionic List Scroll Bug</title>
<link href="http://code.ionicframework.com/nightly/css/ionic.min.css" rel="stylesheet">
<script src="http://code.ionicframework.com/nightly/js/ionic.bundle.min.js"></script>
</head>
<body ng-controller="MyCtrl">
<header class="bar bar-header bar-positive">
<h1 class="title">Ionic List Scroll Bug</h1>
</header>
<ion-content class="has-header">
<ion-scroll delegate-handle="calendarScroll" direction="x">
<div class="row">
<div class="col col-20" ng-repeat="day in payPeriod.days">
<div class="row">
<div class="col">{{day.name}}</div>
</div>
<div class="row">
<div class="col">{{day.number}}</div>
</div>
</div>
</div>
</ion-scroll>
<ion-scroll delegate-handle="taskScroll" direction="y">
<ul class="list">
<li class="list-item" ng-repeat="task in tasks">
<div class="row">
<div class="col col-80">
<p>{{task.name}}</p>
</div>
<div class="col col-20">
<label class="item item-input">
<input type="text" placeholder="Hours" ng-value="task.time" />
</label>
</div>
</div>
</li>
</ul>
</ion-scroll>
</ion-content>
<ion-footer-bar align-title="right" class="bar-stable">
<div class="buttons">
<button class="button">Save</button>
</div>
<h1 class="title">Total hours 0.00</h1>
</ion-footer-bar>
</body>
</html>
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope) {
$scope.payPeriod = {
days: [{ name: 'Mon', number: 3 }, { name: 'Tue', number: 4 }, { name: 'Wed', number: 5 },
{ name: 'Thu', number: 6 }, { name: 'Fri', number: 7 }, { name: 'Sat', number: 8 }, { name: 'Sun', number: 9 }]
};
$scope.tasks = [
{name: 'task 1', time: 1.0 },
{name: 'task 2', time: 3.0 },
{name: 'task 3', time: 2.0 },
{name: 'task 4', time: 1.0 },
{name: 'task 5', time: 2.0 },
{name: 'task 6', time: 1.0 },
{name: 'task 7', time: 1.0 },
{name: 'task 8', time: 2.0 },
{name: 'task 9', time: 1.0 },
{name: 'task 0', time: 1.0 }
];
});
Hybrid work-around for you to try:
Maybe it's not the best solution, but at least allows for scrolling, for you to try, if you like:
Just wrap your whole page content into a <div>
with absolute position and define whether to scroll y and/or x:
<div style='position:absolute; top:0; right:0; bottom:0; left:0; overflow-y:scroll; overflow-x: hidden'>
<!-- your content of page here .... -->
</div>
Worked for me. Browsers compatibility on Windows 10, using ionic-package for Meteor JS (without Angular JS):
:-) shows scrollbar on: - FireFox - Windows 10 Edge - MS IE 11
:-( Does not show scrollbar, but it scrolls: - Safari - Chrome - Opera
Hope this helps a bit for some cases.
Here's a simple solution:
Here's the meat of what we're doing:
ion-scroll[direction=x] {
width: 100vw;
}
ion-scroll[direction=y] {
height: 100vh;
}
That will allow your scrolls to work as expected in your Ionic app (and, in fact, this is what I do in mine as part of the CSS boilerplate).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With