Linha do tempo

by cintia_rodrigues

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.9.8/TweenMax.min.js"></script>
<div>
    <div class="timeCounter">
        <div class="track"></div>
    </div>
</div>

CSS

.timeCounter
{
    width: 100%;
    height: 5px;
    background-color: red;
    z-index:1;
}

.track
{
    height: 100%;
    background-color: #ccc;
    width: 0;
}

JavaScript

var timerTotal = 4;
var maxWidth;
var myTimerAnimation;

$(document).ready(function(){
    maxWidth = $('.timeCounter').width();
    initTimer();
})

function initTimer()
{
    $('.timeCounter .track').css('width', 0);
    myTimerAnimation = TweenMax.to($('.timeCounter .track'), timerTotal, {width: maxWidth, onComplete: initTimer, ease: Linear.easeNone})
}