html - Start Animation from last state it ends CSS -
var app = angular.module('dialapp', ['nganimate']); angular.module('dialapp').controller('maincontroller',['$scope', function ($scope) { $scope.test = 'test'; $scope.left = false; $scope.right = false; $scope.bottom = false; $scope.leftrotate = function () { $scope.left = true; $scope.right = false; $scope.bottom = false; } $scope.rightrotate = function () { $scope.left = false; $scope.right = true; $scope.bottom = false; } $scope.bottomrotate = function () { $scope.left = false; $scope.right = false; $scope.bottom = true; } }]);
body { height: 100%; } .container { padding: 0px; margin: 0px; height: 100%; } .panel-default { border-color: #eff7fa; } .panel-default > .panel-heading { text-align: justify; font-size: large; background-color: #eff7fa; } .panel-body { background-color: #e7f0f4; height: 100%; } .circle { background-color: white; border: 3px solid #ffa003; border-radius: 50%; width: 30px; height: 30px; -webkit-transition: background-color 1s ease-out, transform 1s ease-out; -moz-transition: background-color 1s ease-out, transform 1s ease-out; -o-transition: background-color 1s ease-out, transform 1s ease-out; transition: background-color 1s ease-out, transform 1s ease-out; } .circle:hover { background-color: #ffa003; cursor: pointer; -ms-transform: scale(1.1, 1.1); -moz-transform: scale(1.1, 1.1); -o-transform: scale(1.1, 1.1); /* ie 9 */ -webkit-transform: scale(1.1, 1.1); /* safari */ transform: scale(1.1, 1.1); /* standard syntax */ } .active-circle { background-color: #ffa003; cursor: pointer; -ms-transform: scale(1.1, 1.1); -moz-transform: scale(1.1, 1.1); -o-transform: scale(1.1, 1.1); /* ie 9 */ -webkit-transform: scale(1.1, 1.1); /* safari */ transform: scale(1.1, 1.1); /* standard syntax */ } .p-1 { float: left; line-height: 30px; vertical-align: middle; margin-right: 10px; } .p-2 { float: left; line-height: 30px; vertical-align: middle; margin-left: 10px; } .center-element { margin: auto; text-align: center; } .image-container { position: relative; /* margin-left: -120px; */ width: 100%; text-align: center; } .dial { height: 120px; width: 120px; position: relative; z-index: 1; /*top: 25px;*/ /*animation: rotate 60s infinite steps(60);*/ } .dial:before { background-image: url('http://i.imgur.com/gmzabgi.png'); background-repeat: no-repeat; content: ""; position: absolute; height: 25px; width: 50px; top: -19%; right: 29%; } .dailknob { position: absolute; z-index: 3; height: 60px; width: 60px; top: 25%; left: 170px; } .arrow { position: absolute; z-index: 1; left: 43%; /*animation: rotate 60s infinite steps(60);*/ } .rotate90 { -webkit-animation: rotate90d 1.0s forwards; -webkit-animation-fill-mode: forwards; -moz--animation: rotate90d 1.0s forwards; -moz--animation-fill-mode: forwards; -o-animation: rotate90d 1.0s forwards; -o-animation-fill-mode: forwards; -ms-transform: rotate(90deg) scale(1.3); -ms-animation-fill-mode: forwards; } .rotate180 { -webkit-animation: rotate180d 1.0s forwards; -webkit-animation-fill-mode: forwards; -moz--animation: rotate90d 1.0s forwards; -moz--animation-fill-mode: forwards; -o-animation: rotate90d 1.0s forwards; -o-animation-fill-mode: forwards; -ms-transform: rotate(90deg) scale(1.3); -ms-animation-fill-mode: forwards; /*-webkit-transform: rotate(180deg) scale(1.3); -moz-transform: rotate(180deg) scale(1.3); -o-transform: rotate(180deg) scale(1.3); -ms-transform: rotate(180deg) scale(1.3);*/ } .rotate270 { -webkit-animation: rotate270d 1.0s forwards; -webkit-animation-fill-mode: forwards; -moz--animation: rotate90d 1.0s forwards; -moz--animation-fill-mode: forwards; -o-animation: rotate90d 1.0s forwards; -o-animation-fill-mode: forwards; -ms-transform: rotate(90deg) scale(1.3); -ms-animation-fill-mode: forwards; /*-webkit-transform: rotate(270deg) scale(1.3); -moz-transform: rotate(270deg) scale(1.3); -o-transform: rotate(270deg) scale(1.3); -ms-transform: rotate(270deg) scale(1.3);*/ } @keyframes rotate90d { 100% { transform: rotatez(90deg); } } @keyframes rotate180d { 100% { transform: rotatez(180deg); } } @keyframes rotate270d { 100% { transform: rotatez(270deg); } } .sides { margin-top: 7%; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" /> <body ng-app="dialapp"> <div class="container col-xs-12" ng-controller="maincontroller"> <div class="panel panel-default" style="height: 100%"> <div class="panel-heading"> <p class="panel-heading"> lorem ipsum dolor sit amet, consectetur adipiscing elit. fusce tortor nunc, dapibus et est ut, maximus vehicula ipsum. pellentesque orci purus, maximus eget eros eu, elementum mattis elit. vivamus leo lacus, hendrerit id fringilla et, accumsan nec ligula.ut pulvinar odio massa, vitae molestie eros consectetur non. vivamus nunc lectus, consectetur id ullamcorper venenatis, rutrum in urna. vestibulum @ risus diam. </p> </div> <div class="panel-body"> <div class="col-xs-12" style="margin-top: 10px;"> <div class="col-xs-12 col-md-offset-3 col-md-6" style="height: 120px; margin-bottom: 60px;"> <div class="col-xs-2 sides" > <b class="p-1">yes </b> <div class="circle" style="float: left;" ng-class="{ 'active-circle' : left }" ng-click="leftrotate()"></div> </div> <div class="col-xs-8"> <div class="image-container" style="width: 400px;"> <!-- <img src="images/selectionarrow.png" class="arrow">--> <div class="dial center-element" ng-class="{'rotate270' : left ,'rotate90' : right,'rotate180' : bottom }"> <img src="http://i.imgur.com/fvrs3hs.png"> </div> <img class="dailknob" src="http://i.imgur.com/vrnjqct.png"> </div> </div> <div class="col-xs-2 sides" > <div class="circle" style="float: left;" ng-class="{ 'active-circle' : right }" ng-click="rightrotate()"></div> <b class="p-2">no</b> </div> </div> <div class="col-xs-12 col-md-offset-3 col-md-6"> <div class="col-xs-2 sides"> </div> <div class="col-xs-8"> <div class="image-container" style="width: 400px;"> <div class="circle center-element" ng-class="{ 'active-circle' : bottom }" ng-click="bottomrotate()"></div> <div class="center-element" ><b>may be</b></div> </div> </div> <div class="col-xs-2"> </div> </div> </div> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-animate.min.js"></script>
http://plnkr.co/edit/ou5bucymdydiofuuazeh?p=preview
i want create clock type animation.. in when user click on no -> arrow go close animation when user click on may be... start no may .. now..it start first frame..same may yes..
just use css-transition
instead of css-animation
- for
.dial
element settransition:all 1s ease;
(or custom need). - for
.rotate90
,.rotate180
,.rotate270
instead of animation replacetransform: rotatez(your_deg);
like this:
var app = angular.module('dialapp', ['nganimate']); angular.module('dialapp').controller('maincontroller',['$scope', function ($scope) { $scope.test = 'test'; $scope.left = false; $scope.right = false; $scope.bottom = false; $scope.leftrotate = function () { $scope.left = true; $scope.right = false; $scope.bottom = false; } $scope.rightrotate = function () { $scope.left = false; $scope.right = true; $scope.bottom = false; } $scope.bottomrotate = function () { $scope.left = false; $scope.right = false; $scope.bottom = true; } }]);
body { height: 100%; } .container { padding: 0px; margin: 0px; height: 100%; } .panel-default { border-color: #eff7fa; } .panel-default > .panel-heading { text-align: justify; font-size: large; background-color: #eff7fa; } .panel-body { background-color: #e7f0f4; height: 100%; } .circle { background-color: white; border: 3px solid #ffa003; border-radius: 50%; width: 30px; height: 30px; -webkit-transition: background-color 1s ease-out, transform 1s ease-out; -moz-transition: background-color 1s ease-out, transform 1s ease-out; -o-transition: background-color 1s ease-out, transform 1s ease-out; transition: background-color 1s ease-out, transform 1s ease-out; } .circle:hover { background-color: #ffa003; cursor: pointer; -ms-transform: scale(1.1, 1.1); -moz-transform: scale(1.1, 1.1); -o-transform: scale(1.1, 1.1); /* ie 9 */ -webkit-transform: scale(1.1, 1.1); /* safari */ transform: scale(1.1, 1.1); /* standard syntax */ } .active-circle { background-color: #ffa003; cursor: pointer; -ms-transform: scale(1.1, 1.1); -moz-transform: scale(1.1, 1.1); -o-transform: scale(1.1, 1.1); /* ie 9 */ -webkit-transform: scale(1.1, 1.1); /* safari */ transform: scale(1.1, 1.1); /* standard syntax */ } .p-1 { float: left; line-height: 30px; vertical-align: middle; margin-right: 10px; } .p-2 { float: left; line-height: 30px; vertical-align: middle; margin-left: 10px; } .center-element { margin: auto; text-align: center; } .image-container { position: relative; /* margin-left: -120px; */ width: 100%; text-align: center; } .dial { height: 120px; width: 120px; position: relative; z-index: 1; /* element animate because of */ transition:all 1s ease; } .dial:before { background-image: url('http://i.imgur.com/gmzabgi.png'); background-repeat: no-repeat; content: ""; position: absolute; height: 25px; width: 50px; top: -19%; right: 29%; } .dailknob { position: absolute; z-index: 3; height: 60px; width: 60px; top: 25%; left: 170px; } .arrow { position: absolute; z-index: 1; left: 43%; } .rotate90 { /* use transform instead animation */ transform: rotatez(90deg); } .rotate180 { transform: rotatez(180deg); } .rotate270 { transform: rotatez(270deg); } .sides { margin-top: 7%; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" /> <body ng-app="dialapp"> <div class="container col-xs-12" ng-controller="maincontroller"> <div class="panel panel-default" style="height: 100%"> <div class="panel-heading"> <p class="panel-heading"> lorem ipsum dolor sit amet, consectetur adipiscing elit. fusce tortor nunc, dapibus et est ut, maximus vehicula ipsum. pellentesque orci purus, maximus eget eros eu, elementum mattis elit. vivamus leo lacus, hendrerit id fringilla et, accumsan nec ligula.ut pulvinar odio massa, vitae molestie eros consectetur non. vivamus nunc lectus, consectetur id ullamcorper venenatis, rutrum in urna. vestibulum @ risus diam. </p> </div> <div class="panel-body"> <div class="col-xs-12" style="margin-top: 10px;"> <div class="col-xs-12 col-md-offset-3 col-md-6" style="height: 120px; margin-bottom: 60px;"> <div class="col-xs-2 sides" > <b class="p-1">yes </b> <div class="circle" style="float: left;" ng-class="{ 'active-circle' : left }" ng-click="leftrotate()"></div> </div> <div class="col-xs-8"> <div class="image-container" style="width: 400px;"> <!-- <img src="images/selectionarrow.png" class="arrow">--> <div class="dial center-element" ng-class="{'rotate270' : left ,'rotate90' : right,'rotate180' : bottom }"> <img src="http://i.imgur.com/fvrs3hs.png"> </div> <img class="dailknob" src="http://i.imgur.com/vrnjqct.png"> </div> </div> <div class="col-xs-2 sides" > <div class="circle" style="float: left;" ng-class="{ 'active-circle' : right }" ng-click="rightrotate()"></div> <b class="p-2">no</b> </div> </div> <div class="col-xs-12 col-md-offset-3 col-md-6"> <div class="col-xs-2 sides"> </div> <div class="col-xs-8"> <div class="image-container" style="width: 400px;"> <div class="circle center-element" ng-class="{ 'active-circle' : bottom }" ng-click="bottomrotate()"></div> <div class="center-element" ><b>may be</b></div> </div> </div> <div class="col-xs-2"> </div> </div> </div> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-animate.min.js"></script>
Comments
Post a Comment