Skip to content

Instantly share code, notes, and snippets.

@ramanan12345
Created March 20, 2015 21:08
Show Gist options
  • Select an option

  • Save ramanan12345/14e9e3ec3991bce34d0b to your computer and use it in GitHub Desktop.

Select an option

Save ramanan12345/14e9e3ec3991bce34d0b to your computer and use it in GitHub Desktop.
AngularJS Skills
<div ng-init="skills=[{language: 'Ruby', percentage: 100, color: '#F3C128'}, {language: 'AngularJS', percentage:60, color: '#C799FF'},{language: 'CSS3', percentage:50, color: '#FF5353'}, {language: 'HTML5', percentage: 70, color: '#1CDCFF'}, {language: 'jQuery', percentage: 80, color: '#7CD14E'}]"></div>
<div class="skills" data-timeout="500" data-speed="0.5"></div>
angular.module "myApp", ["myApp.directives"]
angular.module("myApp.directives", []).directive "skills", ->
restrict: "C"
controller: ['$scope', '$element', '$attrs', '$timeout', '$compile', ($scope, $element, $attrs, $timeout, $compile)->
angular.forEach $scope.skills, (value, index)->
time = (Math.random()*1)+parseFloat($attrs.speed)
skill = $compile("<div id='skills_"+value.language.toLowerCase()+"' style='transition: width "+time+"s; -webkit-transition: width "+time+"s; -o-transition: width "+time+"s; -moz-transition: width "+time+"s; background-color: "+value.color+"'><span>"+value.language+"</span></div>")($scope)
$element.append skill
$timeout(->
skill.css({width: value.percentage+'%'})
$attrs.timeout)
]
angular.bootstrap document, ['myApp']
@import "compass/css3";
@import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300&subset=latin,cyrillic);
.skills {
width: 98%;
font-family: 'Open Sans Condensed', sans-serif;
div{
width: 0%;
overflow: hidden;
margin: 10px;
border-radius: 5px;
span{
display: block;
font-size: 18px;
padding: 7px 10px;
text-shadow: 1px 1px #d3d3d3;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment