Files
ionic-framework/test/html/animation.html
2014-05-02 07:56:44 -06:00

91 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html ng-app="myApp">
<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.bundle.js"></script>
<style>
.box {
position: absolute;
width: 100px;
height: 100px;
background-color: black;
}
#opts {
position: absolute;
top: 200px;
left: 10px;
}
</style>
</head>
<body>
<div ng-controller="MyCtrl">
<div class="box"></div>
<div id="opts">
<label>
Duration:
<input type="number" ng-model="anim.duration">
</label>
<label>
Repeat
<input type="number" ng-model="anim.repeat">
</label>
<label>
Delay
<input type="number" ng-model="anim.delay">
</label>
<label>
Auto reverse
<input type="checkbox" ng-model="anim.autoReverse">
</label>
<button ng-click="do('{{v}}')" ng-repeat="v in fns">{{v}}</button>
</div>
</div>
<script>
angular.module('myApp', ['ionic'])
.config(['$ionicAnimationProvider', function($ionicAnimationProvider) {
//$ionicAnimationProvider.setSlowAnimations(true);
}])
.controller('MyCtrl', function($scope, $ionicAnimation) {
$scope.fns = [
'linear',
'ease',
'ease-in',
'ease-out',
'ease-in-out'
];
$scope.anim = {
duration: 500,
delay: 500,
repeat: -1,
autoReverse: false
}
var el = angular.element(document.querySelector('.box'));
$scope.do = function(fn) {
var fadeIn = $ionicAnimation(angular.extend({
el: el,
name: 'fadeIn',
duration: 500,
delay: 500,
autoReverse: false,
repeat: -1,
curve: fn,
step: function(v) {
el[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + (v * 400) + 'px, 0,0)';
}
}, $scope.anim));
fadeIn.start();
}
});
</script>
</body>
</html>