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

              
                div(data-scroll)
	div.smooth-scroll(data-scroll-content)
		header.header.e-rel.e-wvw.e-hvh.e-flex.e-black.e-hidden
			img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole04.jpg", alt="").e-wp.e-hp.e-abs.e-img-fit
			h1.t-white THIS IS HEADER
			
		section.before-footer.e-wvw.e-hvh
			.img
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole04.jpg", alt="")
    		
				
				
		section.e-wvw.e-hvh.master
			.img.e-wp.e-hp
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole03.jpg", alt="").e-wp.e-hp.e-img-fit
		.trg-sticky
		section.before-footer.e-wvw.e-hvh.sticked
			.img
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole03.jpg", alt="")
    			
			
		section.e-wvw.e-hvh.master
			.img.e-wp.e-hp
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole02.jpg", alt="").e-wp.e-hp.e-img-fit
		.trg-sticky
		section.before-footer.e-wvw.e-hvh.sticked
			.img
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole02.jpg", alt="")
    
		
		
		
		section.e-wvw.e-hvh.master
			.img.e-wp.e-hp
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole05.jpg", alt="").e-wp.e-hp.e-img-fit
		.trg-sticky
		section.before-footer.e-wvw.e-hvh.sticked
			.img
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole05.jpg", alt="")
    
		
		section.before-footer.e-wvw.e-hvh.super-before
			.img
				img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole04.jpg", alt="")
    		
		
		footer.footer.e-wvw.e-hvh
			.footer__hold
				.links
					each list, index in ['About us', 'Portfolio', 'Services', 'Works', 'Home', 'Contact']
						h2=list

				.infos
					p 19144, Cruickshank Avenue<br> Baie-d’Urfé (Québec)<br> H9X 3P1 Canada

				.infos
					p 19144, Cruickshank Avenue<br> Baie-d’Urfé (Québec)<br> H9X 3P1 Canada
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Poppins:200&display=swap')
body
	background: #000
	font-family: "Poppins",sans-serif
	//text-transform: uppercase

h1
	font-size: 9vw
	z-index: 1


section
	width: 100vw
	height: 100vh
	position: relative
	background: #000

.before-footer
	display: flex
	align-items: center
	justify-content: center

	.img
		width: 55vw
		height: 55vh
		position: relative
	
		img
			width: 100%
			height: 100%
			object-fit: cover

.footer
	cursor: pointer
	background: #dcc8ac
	width: 100vw
	height: 100vh
	display: flex
	align-items: center
	justify-content: center

	&__hold
		width: 80vw
		display: flex
		justify-content: space-between
		align-items: flex-end

		h2
			font-size: 3.5vw
			padding: 10px 0
		p
			line-height: 25px
	
.master
	position: relative
	z-index: 1

.sticked
	transform: translateY(-100vh)

.super-before
	position: relative
	z-index: 2
	
              
            
!

JS

              
                console.clear();

let h = window.innerHeight
let w = window.innerWidth
    //
    // Pin Works
    //-------------------------------------------------

let $header = $('header.header')
let $footer = $('footer.footer')
let $trgSticky = document.querySelectorAll('.trg-sticky')
let stickies = []
$trgSticky.forEach(function(item){
	stickies.push(item)
})



  function pinned(scrolled){

		
		
		
	//? - =========================  FAKE STICKY  ========================= -//
	//? - =========================  FAKE STICKY  ========================= -//
	$trgSticky.forEach(function(item, index){
		let itemPosition = item.getBoundingClientRect().top
		let itemBottom = item.getBoundingClientRect().bottom
		let fakeOffset = ((scrolled * -1) - (itemPosition - window.innerHeight)) * - 1
		if(itemPosition <  (window.innerHeight * 1.1) && itemBottom > 0) {
				let percentageDuration = (scrolled - fakeOffset) / ((fakeOffset + (window.innerHeight * 1.5)) - fakeOffset)
				gsap.set($('.sticked').eq(index), { yPercent:  (150 * percentageDuration)})
		}
	})
		
		
		
    //______________ HEADER
		if(scrolled < h) {
			let percentHeader = scrolled / h
      gsap.set($header, { yPercent:  (40* percentHeader)})
      gsap.set($header.find('img'), { scale: 1 + ((1.03 * percentHeader) / 3)})
		}
		
		
		
    
    //______________ FOOTER PARALLAX
    let sizeDocument =  $('[data-scroll-content]').height()
    //console.log(sizeDocument - (h * 2))
		
    if(scrolled > sizeDocument - (h * 2)) {
      let percentageFromTop =  ((sizeDocument - h) - scrolled) / h
      gsap.set($footer, { y: - (h * percentageFromTop)})
      gsap.set($footer, { yPercent:  (30 * percentageFromTop)})
    }

    
} //close pinned

        
        
        

function smoothScroll() {
  if($(window).width() > 80) {
  
    const math = {
        lerp: (a, b, n) => {
            return (1 - n) * a + n * b
        },
        norm: (value, min, max) => {
              return (value - min) / (max - min)
        }
      
    }
    
    const config = {
      height: window.innerHeight,
      width: window.innerWidth
    }
    
    class Smooth {
      constructor() {
        this.bindMethods()
    
        this.data = {
          ease: 0.085,
          current: 0,
          last: 0
        }
    
        this.dom = {
          el: document.querySelector('[data-scroll]'),
          content: document.querySelector('[data-scroll-content]')
        }
    
        this.rAF = null
    
        this.init()
      }
    
      bindMethods() {
        ['scroll', 'run', 'resize']
        .forEach((fn) => this[fn] = this[fn].bind(this))
      }
    
      setStyles() {
        this.dom.el.style.position = 'fixed';
        this.dom.el.style.top = 0;
        this.dom.el.style.left = 0;
        this.dom.el.style.height = '100%'
        this.dom.el.style.width = '100%'
        this.dom.el.style.overflow = 'hidden'   
      }
    
      setHeight() {
        document.body.style.height = `${this.dom.content.offsetHeight}px`
      }
    
      resize() {
        this.setHeight()
        this.scroll()
      }
    
    
    
      scroll() {
        this.data.current = window.scrollY
      }
    
      run() {
        this.data.last = math.lerp(this.data.last, this.data.current, this.data.ease)
        this.data.last = Math.floor(this.data.last * 100) / 100
        
        const diff = this.data.current - this.data.last
        const acc = diff / config.width
        const velo =+ acc
        
          //console.log(velo)
        this.dom.content.style.transform = `translate3d(0, -${this.data.last.toFixed(0)}px, 0) `
        
        
        //call pinned
        pinned(this.data.last)
        
        this.requestAnimationFrame()
      }
        
    
      on(requestAnimationFrame = true) { 
        this.setStyles()
        this.setHeight()
        this.addEvents()
    
        requestAnimationFrame && this.requestAnimationFrame()
      }
    
      off(cancelAnimationFrame = true) {
        cancelAnimationFrame && this.cancelAnimationFrame()
    
        this.removeEvents()
      }
    
      requestAnimationFrame() {
        this.rAF = requestAnimationFrame(this.run)
      }
    
      cancelAnimationFrame() {
        cancelAnimationFrame(this.rAF)
      }
    
      destroy() {
        document.body.style.height = ''
    
        this.data = null
    
        this.removeEvents()
        this.cancelAnimationFrame()
      }
    
      resize() {
        this.setHeight()
      }
    
      addEvents() {
        window.addEventListener('resize', this.resize, { passive: true })
        window.addEventListener('scroll', this.scroll, { passive: true })
      }
    
      removeEvents() {
        window.removeEventListener('resize', this.resize, { passive: true })
        window.removeEventListener('scroll', this.scroll, { passive: true })
      }
    
      init() {
        this.on()
      }
    }
    const smooth = new Smooth()
  }
}//close menu


smoothScroll() 
              
            
!
999px

Console