This commit is contained in:
Max Lynch
2014-01-22 09:02:36 -06:00
parent 9f82ca1f27
commit 78f0242fd2
3 changed files with 42 additions and 9 deletions

View File

@@ -1265,7 +1265,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
// Otherwise, supercharge this baby!
$timeout(function() {
var hasBouncing = $scope.$eval($scope.hasBouncing);
var enableBouncing = !$ionicPlatform.is('Android') && hasBouncing !== false;
var enableBouncing = (!$ionicPlatform.is('Android') && hasBouncing !== false) || hasBouncing === true;
// No bouncing by default for Android users, lest they take up pitchforks
// to our bouncing goodness
sv = new ionic.views.Scroll({

View File

@@ -80,7 +80,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
// Otherwise, supercharge this baby!
$timeout(function() {
var hasBouncing = $scope.$eval($scope.hasBouncing);
var enableBouncing = !$ionicPlatform.is('Android') && hasBouncing !== false;
var enableBouncing = (!$ionicPlatform.is('Android') && hasBouncing !== false) || hasBouncing === true;
// No bouncing by default for Android users, lest they take up pitchforks
// to our bouncing goodness
sv = new ionic.views.Scroll({

View File

@@ -1,7 +1,15 @@
describe('Ionic Content directive', function() {
var compile, element, scope;
var compile, element, scope, platform = 'Android';
beforeEach(module('ionic'));
//beforeEach(module('ionic'));
beforeEach(module('ionic', function ($provide) {
$provide.value('$ionicPlatform', {
is: function(type) {
return type === platform;
}
});
}));
beforeEach(inject(function($compile, $rootScope, $timeout, $window) {
compile = $compile;
@@ -28,11 +36,26 @@ describe('Ionic Content directive', function() {
expect(scrollElement.hasClass('padding')).toEqual(true);
});
/**
* Not currently possible to mock this AFAIK
*/
xit('Disables bouncing by default on Android', function() {
window.navigator.userAgent = 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30';
it('Enables bouncing by default', function() {
platform = 'iPhone';
element = compile('<content has-header="true"></content>')(scope);
timeout.flush();
var newScope = element.isolateScope();
var scrollView = scope.scrollView;
expect(scrollView.options.bouncing).toBe(true);
});
it('Disables bouncing when has-bouncing = false', function() {
platform = 'iPhone';
element = compile('<content has-header="true" has-bouncing="false"></content>')(scope);
timeout.flush();
var newScope = element.isolateScope();
var scrollView = scope.scrollView;
expect(scrollView.options.bouncing).toBe(false);
});
it('Disables bouncing by default on Android', function() {
platform = 'Android';
element = compile('<content has-header="true"></content>')(scope);
timeout.flush();
var newScope = element.isolateScope();
@@ -40,6 +63,16 @@ describe('Ionic Content directive', function() {
expect(scrollView.options.bouncing).toBe(false);
});
it('Disables bouncing by default on Android unless has-bouncing = true', function() {
platform = 'Android';
element = compile('<content has-header="true" has-bouncing="true"></content>')(scope);
timeout.flush();
var newScope = element.isolateScope();
var scrollView = scope.scrollView;
expect(scrollView.options.bouncing).toBe(true);
});
it('Should set start x and y', function() {
element = compile('<content start-x="100" start-y="300" has-header="true"></content>')(scope);
timeout.flush();