Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
JS
/* * Javascript for the progress bar * @author - Yane */ $(document).ready(function() { var pBar = $('.progress-bar'); var spark = $('.loader-spark'); var firework = $('.firework'); var lTitleVal = $('.loading-title-val'); var lTitleWait = $('.loading-title-wait'); var mainContainer = $('.main-container') var loadMax = pBar.attr('max'); var loadValue = pBar.val(); var sparStartPos = spark.position().left; var pBarWidth = $('.progress-bar').width(); var pBarStep = pBarWidth/loadMax; // A function to update the progress bar and spark values // retruns 'loaded' when it's done var loadingUpdate = function ( val ){ addValue = pBar.val(val); spark.css( 'left', (sparStartPos + val*pBarStep) + 'px' ); lTitleVal.text( val+'%' ); if ( val == loadMax ){ spark.hide(); lTitleWait.text( 'Loaded! Launching it!' ); launchIt(); return 'loaded'; }else{ return 'loading'; } } // An action to take after it's loaded var launchIt = function (){ spriteAnimation( firework, 40, 30, 0, 9, false, function(){ spriteAnimation( firework, 40, 30, 9, 18, true, false); firework.delay(300).animate({top:"-200px"}, 1000, function(){ mainContainer.fadeTo(100,0.4).fadeTo(100,0.9).fadeTo(100,0.4).fadeTo(100,0.9).fadeOut(300); }); }); } // Function for the sprite animation var spriteAnimation = function ( el, spriteWidth, spriteAnimFrame, frameStart, frameCount, loop, fallback ){ var frame = frameStart; var animateSprite = function(){ frame ++; $( el ).css('background-position','-'+(frame*spriteWidth)+'px 0'); if ( frame < frameCount ) { setTimeout(function() { animateSprite( ); }, spriteAnimFrame); }else{ if ( loop ){ frame = frameStart; animateSprite( ); }else{ if( fallback ){ try { fallback(); } catch(err) { } } } } } animateSprite(); } // simuating loading in order to show how it works, since we have actually // nothing to load currently var simulateLoading = function(){ var timeInterval = (1000/loadMax)*5; var loading = function() { loadValue += 1; if (loadingUpdate(loadValue) == 'loaded') { clearInterval(animateProgress); } }; var animateProgress = setInterval(function() { loading(); }, timeInterval); } spriteAnimation( spark, 15, 30, 0, 10, true, false ); simulateLoading(); });
CSS
/* ======================= Page Load Styles @autor: Yane Frenski ===================== */ html, body{ height: 100%; margin: 0; paddin: 0; } body{ background: white; } .main-container{ height:100%; position: relative; background-color: #231e1f; } .loader-container{ width: 200px; position: absolute; top: 50%; left: 50%; margin-left: -120px; font-family: Georgia, Times, 'Times New Roman', serif; } .progress-bar{ border: none; width: 200px; height: 1px; background-color:#a8a8a8; } .progress-bar[value]::-webkit-progress-bar { background-color:#a8a8a8; } .progress-bar[value]::-webkit-progress-value { background-color:#231E1F; } .progress-bar[value]::-moz-progress-bar { background-color:#231E1F; } .progress-bar[aria-valuenow]:before { background: #231E1F; } .loader-spark{ width: 15px; height: 15px; background: url('http://78.47.222.66/snippets/progress-bar/img/spark.png') no-repeat left top; position: absolute; top: 10px; left: -10px; } .loading-title{ font-size: 1em; font-style: italic; color: #e9d9c6; text-align: center; font-weight: normal; margin: 30px 0 0 0; } .loading-title .loading-title-val{ display: block; color: #ffae05; margin-bottom: 10px; } .firework{ width: 40px; height: 105px; background: url('http://78.47.222.66/snippets/progress-bar/img/firework.png') no-repeat 0 0; position: absolute; top: 50%; left: 50%; margin-left: 70px; margin-top: -51px; }
HTML
Loader
0%
Loading, please wait
Join Effecthub.com
Working with Global Gaming Artists and Developers!
Login
Sign Up
Or Login with Your Email Address:
Email
Password
Remember
Or Sign Up with Your Email Address:
Your Email
This field must contain a valid email
Set Password
Password should be at least 1 character
Stay informed via email