Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                
    <body class="is-loading">
 
        <div id="intro" class="header-container fs">
          
              <div class="slider-controls">
                <div data-slide="0" class="active">1</div>
                <div data-slide="1">2</div>
                <div data-slide="2">3</div>
              </div>
          
              <div class="slider"> 
                <div class="mask-slide"></div>
                <div class="bcg slide first"></div>
                <div class="bcg slide second"></div>
                <div class="bcg slide third"></div>
              </div>
               
        </div>


    </body> 
              
            
!

CSS

              
                body {
  background-color: #212121;
}

html,
body {
  height: 100%;
  margin: 0;
}
.active{
  color:red;
}
 .slide {
    width: 100%;

    &.first {
       background-image: url(https://ihatetomatoes.net/demos/scrollmagic-templates/scrollmagic-template-04/img/img_mountains01.jpg);
    }

    &.second {
         background-image: url(https://ihatetomatoes.net/demos/scrollmagic-templates/scrollmagic-template-04/img/img_mountains02.jpg);
    } 
    &.third {
         background-image: url(https://ihatetomatoes.net/demos/scrollmagic-templates/scrollmagic-template-04/img/img_mountains03.jpg);
    } 
}
  

.mask-slide {
    position: absolute;
    background: rgba(0,0,0, 0.55);
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    z-index: 2;
}


/* =Preloader */

#preloader {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 101;
  background-color: #212121;
  color: #ffffff;
}

#preloader .txt {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

#preloader .txt-perc {
  font-size: 35px;
  font-family: 'Roboto Condensed', Helvetica, Helvetica Neue, Arial, sans-serif;
  opacity: 1;
  margin: 0 0 6px 0;
  max-width: 400px;
  text-align: center;
}

#preloader .progress {
  width: 100px;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.2);
  margin: 0 auto 15px auto;
}

#preloader .progress span {
  display: block;
  width: 0;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
}

#preloader.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.is-loading {
  overflow: hidden;
}


/* =Header */

.header-container {
  text-align: center;
  color: #ffffff;
}

.header-container .wrapper {
  padding-top: 120px;
  z-index: 2;
  position: relative;
}

.header-container .bcg {
  -webkit-transition: -webkit-transform 4s ease-out;
  transition: transform 4s ease-out;
  -webkit-transform: scale(1.05);
  -ms-transform: scale(1.05);
  transform: scale(1.05);
  -webkit-transform-origin: top center;
  -ms-transform-origin: top center;
  transform-origin: top center;
}

.header-container.is-loaded .bcg {
  -webkit-transform: scale(1);
  -ms-transform: scale(1);
  transform: scale(1);
}



.bcg {
  background: no-repeat center center;
  background-size: cover;
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.5;
} 
              
            
!

JS

              
                (function($) { 
     class Slider {
		  constructor () {
		    this.controls  = document.querySelectorAll('.slider-controls div')
		    this.slides    = document.querySelectorAll('.slider .slide')
		    this.mask      = document.querySelectorAll('.mask-slide')
		    this.index     = 0
		    this.isPlaying = false
		    this.timer     = false
		    this.interval
		    this.init()
		    this.initEvents()
		  }
		  
		  init () {
		    this.interval = setInterval(() => {
		      this.play()
		    }, 9000)
		    this.timer = true
		  }
		  
		  initEvents () {
		    this.controls.forEach(control => control.addEventListener('click', (e) => this.switchSlide(e)))
		  }
		  
		  switchSlide (e) {
		    if (this.isPlaying) {
		      return
		    }
		    
			    const current             = document.querySelector('.slider-controls .active')
			    const slideCurrent        = current.getAttribute('data-slide')
			    const target = e.target
			    const slideTarget = target.getAttribute('data-slide')
			    const slideTargetElement = this.slides[slideTarget - 1]
		    
		    if (slideCurrent === slideTarget) {
		      return
		    }
		    
		    clearInterval(this.interval)
		    this.timer = false
		    this.play(target, slideTarget)
		  }
		  
		  play (target, slideTarget) {
		    const currentIndex = this.index
		    let nextIndex      = Number(slideTarget) || this.index + 1
		    
		    if (nextIndex > this.slides.length - 1) {
		      nextIndex = 0
		    }
		    
		    const activeNav = target || this.controls[nextIndex]
		    
		    this.isPlaying = true
		    this.controls.forEach(control => control.classList.remove('active'))
		    activeNav.classList.add('active')
		    
		    const tl = new TimelineMax({ onComplete: () => {
		      TweenMax.set(this.slides[currentIndex], { left: 0, right: 'initial' })
		      TweenMax.set(this.mask, { autoAlpha: 0, })
		      this.isPlaying = false
		      this.index = nextIndex
		      if (!this.timer) {
		        this.interval = setInterval(() => {
		          this.play()
		        }, 9000)
		        this.timer = true
		      }
		    }})
		    
		    tl.to(this.mask, 1, {autoAlpha: 1, ease: Power4.easeInOut, })
		    
		    tl.set(this.slides[currentIndex], {autoAlpha: 0, }) 

		    tl.to(this.mask, 1, {autoAlpha: 1, ease: Power4.easeInOut })
		    
		    tl.to(this.slides[nextIndex], 1, {autoAlpha: 1, ease: Power4.easeInOut }, '-=1')

		  }
		}
     const horizonSlider = new Slider();

  
}(jQuery));
              
            
!
999px

Console