Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="container">

    <div class="images">
       <img src='' alt=''>
        <img src='' alt=''>
        <img src='' alt=''>
        <img src='' alt=''>
        <img src='' alt=''>
        <img src='' alt=''>
        <img src='' alt=''>

    <div class="load-bar">
        <p class="value">0%</p>
        <div class="bar"></div>



                /* **************************************** */
/* Default CSS styles being imported from:
/* **************************************** */

/* ****************** */
/* Notes and reminders
/* ****************** */

/* ****************** */
/* Local CSS styling
/* ****************** */
.container {
    position: relative;
    min-height: 200px;
    overflow: hidden;

.images {
    position: relative;
.images > img {
    max-height: 300px;
    max-width: 100%;

.load-bar {
    text-align: center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    opacity: 0.95;



                // Now let's work with functions creating objects
// They're the building blocks in javascript
var LoaderBar = function(parentElement) {
    this.parent = parentElement;
    this.holder = this.parent.querySelector(".load-bar"); = this.parent.querySelector(".bar");
    this.display = this.parent.querySelector(".value");
    this.loadingTargets = this.parent.querySelectorAll("img");
    this.targetsToLoad = this.loadingTargets.length;
    this.targetsLoaded = 0;
    // Set the tween up on instantiation
    this.tween = this.setTween();
    // Listen to the loaded event of the loading targets
    for(var i = 0; i < this.loadingTargets.length; i++) {
        // Watch out for the scoping gotcha
        // You need to bind the targetLoaded to the LoaderBar scope
        this.loadingTargets[i].addEventListener("load", this.targetLoaded.bind(this));

// This is like extending a class in other programming languages
LoaderBar.prototype.setTween = function() {
    return TweenMax.from(, 1, {
        transformOrigin:"0 0",
        onUpdate:function() {
            this.display.textContent = Math.round(this.tween.progress() * 100) + "%";
        onUpdateScope:this, // make sure you scope the onUpdate method

LoaderBar.prototype.targetLoaded = function() {
    const percentLoaded = this.targetsLoaded / this.targetsToLoad;
    console.log("targets loaded", this.targetsToLoad, this.targetsLoaded, percentLoaded);
    // Whenever one target finished loading move the tween to a fraction of the total, 0.5, {
        progress: percentLoaded

LoaderBar.prototype.hide = function() {, 1, {

// Create a new instace of the LoaderBar
var thisBar = new LoaderBar(document.querySelector(".container"));