Created
March 22, 2013 13:35
-
-
Save thathurtabit/5221309 to your computer and use it in GitHub Desktop.
A CodePen by Stephen Fairbanks. Super Simple Progress Bar - This progress bar uses the HTML5 custom data-* attribute to allow for quick updating to a progress bar animated by Zepto (or jQuery). The animation is wrapped in a window.resize function to reanimate if the browser size is changed.
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-wrap progress" data-progress-percent="22"> | |
<div class="progress-bar progress"></div> | |
</div> |
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
// on page load... | |
moveProgressBar(); | |
// on browser resize... | |
$(window).resize(function() { | |
moveProgressBar(); | |
}); | |
// SIGNATURE PROGRESS | |
function moveProgressBar() { | |
console.log("moveProgressBar"); | |
var getPercent = ($('.progress-wrap').data('progress-percent') / 100); | |
var getProgressWrapWidth = $('.progress-wrap').width(); | |
var progressTotal = getPercent * getProgressWrapWidth; | |
var animationLength = 2500; | |
// on page load, animate percentage bar to data percentage length | |
$('.progress-bar').animate({ | |
left: progressTotal | |
}, animationLength, 'ease-in-out'); | |
} |
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
@import "compass"; | |
.progress { | |
width: 100%; | |
height: 50px; | |
} | |
.progress-wrap { | |
background: #f80; | |
margin: 20px 0; | |
overflow: hidden; | |
position: relative; | |
.progress-bar { | |
background: #ddd; | |
left: 0; | |
position: absolute; | |
top: 0; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment