Support slowing animations (for debugging)

This commit is contained in:
Max Lynch
2014-05-01 13:34:42 -05:00
committed by Andy Joslin
parent 4bea189a11
commit 2872cf603e
3 changed files with 23 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
/**
* @ngdoc service
* @name $ionicAnimation
@@ -45,14 +46,16 @@
*
*/
IonicModule
.factory('$ionicAnimation', [
'$rootScope',
'$document',
'$compile',
'$timeout',
'$interval',
function($rootScope, $document, $compile, $timeout, $interval) {
return function(opts) {
return ionic.Animation.create(opts);
}
}]);
.provider('$ionicAnimation', function() {
var useSlowAnimations = false;
this.setSlowAnimations = function(isSlow) {
useSlowAnimations = isSlow;
};
this.$get = [function() {
return function(opts) {
opts.useSlowAnimations = useSlowAnimations;
return ionic.Animation.create(opts);
}
}]
});

View File

@@ -71,6 +71,12 @@
*/
ionic.Animation.Animation = function(opts) {
ionic.extend(this, opts);
if(opts.useSlowAnimations) {
console.warn('Running animation', opts.name, 'with SLOW animations (duration and delay increased by 3x)');
this.delay *= 3;
this.duration *= 3;
}
};
ionic.Animation.Animation.prototype = {

View File

@@ -50,6 +50,9 @@
<script>
angular.module('myApp', ['ionic'])
.config(['$ionicAnimationProvider', function($ionicAnimationProvider) {
//$ionicAnimationProvider.setSlowAnimations(true);
}])
.controller('MyCtrl', function($scope, $ionicAnimation) {
$scope.fns = [
'linear',