Fireworks (animation)

Created in HTML, CSS, and Javascript web technologies.

by William Green

HTML

<div id="projectContainer">
    <div id="starSuperContainer">
        <div id="starContainer"></div>
        <div id="starFade"></div>
    </div>
    <div id="fireworksContainer"></div>
</div>

CSS

#projectContainer {
    background-color: #333;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
}
#starSuperContainer {
    width: 100vw;
    height: 70vh;
    position: relative;
}
#starContainer {
    width: 100%;
    height: 100%;
}
#starFade {
    width: 100%;
    height: 100%;
    background: -webkit-linear-gradient(transparent, #333);
    /* For Safari 5.1 to 6.0 */
    background: -o-linear-gradient(transparent, #333);
    /* For Opera 11.1 to 12.0 */
    background: -moz-linear-gradient(transparent, #333);
    /* For Firefox 3.6 to 15 */
    background: linear-gradient(transparent, #333);
    /* Standard syntax */
    position: absolute;
    top: 0;
}
.star {
    background-color: #fff;
    border-radius: 50%;
    position: fixed;
}
.fireworkContainer {
    /*width:20px;
                height:20px;*/
    margin-top: -4px;
    margin-bottom: -4px;
    position: absolute;
    display: inline-block;
    -o-transition: all 1s linear, opacity 2s linear;
    -moz-transition: all 1s linear, opacity 2s linear;
    -webkit-transition: all 1s linear, opacity 2s linear;
    -ms-transition: all 1s linear, opacity 2s linear;
    transition: all 1s linear, opacity 2s linear;
    bottom: 0;
    border-radius: 50%;
    -webkit-filter: blur(1px);
    -moz-filter: blur(1px);
    -ms-filter: blur(1px);
    -o-filter: blur(1px);
    filter: blur(1px);
}
.fireworkContainer * {
    -o-transition: all .8s linear, opacity .1s linear;
    -moz-transition: all .8s linear, opacity .1s linear;
    -webkit-transition: all .8s linear, opacity .1s linear;
    -ms-transition: all .8s linear, opacity .1s linear;
    transition: all .8s linear, opaciyt .1s linear;
    position: absolute;
    width: 0;
    height: 0;
    -o-transform-origin: bottom center;
    -moz-transform-origin: bottom center;
    -webkit-transform-origin: bottom center;
   ...

JavaScript

/*settings variables*/
var fireworkDimensions = 10; //make each firework 10px in width and height
var fireworkTransitionTime = 1000; //in milliseconds
var resizeTimer = false; //resize delay timer (not set)
var rayWidth = 2; //width of firework ray
var rayLength = 100; //length of firework ray
var fireworkRayPositions = [
    [0, 3],
    [10, 5],
    [8, 6],
    [5, 8],
    [2, 8],
    [2, 6],
    [0, 4],
    [0, 2],
    [2, 2],
    [4, 0],
    [8, 2],
    [10, 2]
]; //firework array positions in px format: bottom,right
var blurLights = true;
var windowWidth = window.innerWidth; //get width of viewport (updated when window is resized)
var windowHeight = window.innerHeight; //get height of viewport (updated when window is resized)

// IF THE BROWSER IS INTERNET EXPLORER 10 OR 11 disable the blurring background
var UAString = navigator.userAgent;
if ((navigator.appVersion.indexOf("MSIE 10") != -1) || (UAString.indexOf("Trident") !== -1 && UAString.indexOf("rv:11") !== -1)) {
    //ie 10 and 11 don't support filter blurring so disable it in the program
    blurLights = false;
}

var fireworkCounter = 0; //count how many fireworks have exploded
var fireworkRayRotation = [0, -30, -60, -90, -120, -150, -180, -210, -240, 90, 60, 30]; //the rotation of each ray of an exploded firework

window.addEventListener('load', function () {
    initialize(); //initialize everything when the page loads
});

function initialize() {
    fireworkTimers = []; //create empty global array to store all the timeouts for the firework explode time
    createStars(); //call function to create the star background
    createFireworks(); //call function to create the fireworks

    function createStars() { //function create stars
        var starContainer = document.getElementById('starContainer'); //get the container
        starContainer.innerHTML = ''; //empty it incase anything is already in it
        for (var i = 0; i < window.innerWidth; i++) { //add a star for each pixel of the viewport...