Effeckt Buttons With AngularJS
A demo of animations with AngularjS and Effeckts
by Josh Kurz
HTML
<script src="http://code.angularjs.org/snapshot/angular.js"></script>
<script src="http://code.angularjs.org/snapshot/angular-animate.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<div class="well container">
<select ng-model="animationType" ng-options="option for option in animationOptions"></select>
<button class="effeckt-button btn" ng-repeat="player in players" data-effeckt-type="{{animationType}}" ng-click="loadPowers(player)">
<span class="label">{{player.name}}</span>
<span class="spinner"></span>
</button>
</div>
CSS
.effeckt-button {
position: relative;
background: skyblue;
color: white;
border: 0;
padding: 0.8rem 1rem;
font-family: inherit;
font-size: 1.3em;
margin: 0 0.25rem 0.6rem 0;
white-space: nowrap;
cursor: pointer;
outline: none;
-webkit-appearance: none;
-webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.effeckt-button .spinner {
position: absolute;
width: 32px;
height: 32px;
top: 50%;
margin-top: -16px;
margin-left: -16px;
opacity: 0;
background-image:...
JavaScript
var app = angular.module('effecktDemo', [])
.controller('demoCtrl', ['$scope', '$timeout', function($scope, $timeout){
$scope.animationType = 'slide-right';
$scope.animationOptions = ['slide-right', 'expand-right', 'expand-left', 'expand-up', 'expand-down', 'slide-left', 'slide-up', 'slide-down', 'zoom-in', 'zoom-out'];
$scope.players = [{"name": "Johnny Bravo", "powers": ["mojo"]},{"name": "Superman", "powers": ["*"]},{"name": "Catwoman", "powers": ["climbing","scratching"]},{"name": "Robin", "powers": ["sidekicking", "diversions"]},{"name": "Yoda", "power": ["force","lightsaber"]}];
}])
.directive('effecktButton', ['$timeout', function($timeout){
return {
restrict: 'AC',
link: function(scope, element, attrs){
scope.loadPowers = function(){
if(element.attr('data-loading')){
element.removeAttr('data-loading');
} else {
element.attr('data-loading', true);
$timeout(function(){
element.removeAttr('data-loading');
},2000);
}
}
}
}
}]);