Created
May 29, 2013 21:58
-
-
Save zoobestik/5674164 to your computer and use it in GitHub Desktop.
Example for veiw for progress bar with animation.
In action: http://jsfiddle.net/zoobestik/USQfv/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="progress-bar"> | |
<div class="progress-bar__line"> | |
<div class="progress-bar__line2"></div> | |
</div> | |
</div> | |
<button data-to="75">resize 75%</button> | |
<button data-to="20">resize 20%</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function progress(value, max) { | |
if (max === undefined) { | |
max = 100; | |
} | |
if (value >= max) { | |
value = max; | |
} | |
var k = value / max; | |
var insideWidth = parseInt($('.progress-bar').width() * k, 10); | |
$('.progress-bar__line').width(insideWidth); | |
} | |
$(function() { | |
$('body').on('click', 'button', function () { | |
var per = $(this).data('to'); | |
progress(per); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background:#2B3036; | |
} | |
.progress-bar { | |
background:#191C21; | |
border-radius:20px; | |
box-shadow:inset 0px 1px 4px black; | |
padding:2px; | |
height:15px; | |
width:80%; | |
margin:100px auto; | |
} | |
.progress-bar__line { | |
background:#191C21; | |
background:linear-gradient(to bottom, #D1E795 0%, #7BAE37 100%); | |
border-radius:12px; | |
height:15px; | |
-webkit-transition:width 1s ease; | |
transition:width 1s ease; | |
} | |
.progress-bar__line2 { | |
color:#fff; | |
text-align:center; | |
font-size:bold; | |
width:100%; | |
height:15px; | |
border-radius:20px; | |
-webkit-animation:progress 1.2s linear infinite; | |
animation:progress 1.2s linear infinite; | |
background-repeat:repeat-x; | |
background-size:15px 15px; | |
background-image:linear-gradient(-45deg, rgba(255, 255, 255, 0.25) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.25) 50%, rgba(255, 255, 255, 0.25) 75%, transparent 75%, transparent); | |
} | |
@-webkit-keyframes progress { | |
to { | |
background-position: 15px 0; | |
} | |
} | |
@-moz-keyframes progress { | |
to { | |
background-position: 15px 0; | |
} | |
} | |
@keyframes progress { | |
to { | |
background-position: 15px 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment