Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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 class="grid">
    <div class="columns">
        <div class="column-wrap">
            <div class="column">
                <div class="column__item">
                    <div class="menu-item menu-item-first"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-first"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-first"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-first"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-first"><div class="image-box"><div class="image"></div></div></div>
                </div>
            </div>
        </div>
        <div class="column-wrap">
            <div class="column">
                <div class="column__item">
                    <div class="menu-item menu-item-sec"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-sec"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-sec"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-sec"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item menu-item-sec"><div class="image-box"><div class="image"></div></div></div>
                </div>
            </div>
        </div>
        <div class="column-wrap">
            <div class="column">
                <div class="column__item">
                    <div class="menu-item"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item"><div class="image-box"><div class="image"></div></div></div>
                    <div class="menu-item"><div class="image-box"><div class="image"></div></div></div>
                </div>
            </div>
        </div>
    </div>
</div>

              
            
!

CSS

              
                
//GUI

@mixin flex-center(){
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    justify-content: center;
    align-items: center;
}

@mixin image-box(){
    position: relative;
    width: 80%;
    height: 70vh;
    overflow: hidden;
    margin:0 auto;
    background-color:#dedede;

}
@mixin image() {
    position: absolute;
    left:0;
    top:0;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

// Colors

$light-bg:#F9F6E7;
$bg-color: #E2DFD3;
$dot-color:#F9F6E7;

// Dimensions squares
$dot-size: 83px;
$dot-space: 84px;


html{
    height: 100%;
    width: 100%;
}

body{
    overflow: hidden;
    margin:0;
    padding: 0;
    font-size: 1rem;
    background:
		linear-gradient(90deg, $bg-color ($dot-space - $dot-size), transparent 1%) center,
		linear-gradient($bg-color ($dot-space - $dot-size), transparent 1%) center,
		$dot-color;
	background-size: $dot-space $dot-space;
}


header{
    position: absolute;
    width: 100%;
    .nav-container{
        padding:2.5em 5em;
        @include flex-center;
        justify-content: space-between;
    }
}

//infinite columns

.columns{
    display: flex;
    position: relative;
    justify-content: center;
    padding: 0 3rem;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    .column-wrap{
        display: flex;
        position: relative;
        height: 100vh;
        width: 33.3%;
        margin: 0 auto;
        .column{
            position: relative;
            display: flex;
            width: 100%;
            &__item{
                margin: 0;
                position: relative;
                z-index: 1;
                height: 100%;
                width: 100%;
                .menu-item{
                    position: absolute;
                    z-index: 1;
                    width: 100%;
                    padding: 2rem 0;
                    text-align: center;
                }
            }
        }
    }
}

.image-box{
    @include image-box;
    .image{
    @include image;
    }
}

.wrapper{
    position: fixed;
    z-index: 99;
    top: 0px;
    left: 0px;
    width: 100%;
    display: block;
    height: 100vh;
    overflow: hidden;
    border: 1px solid red;
  }
  .wrapper-items{
    position: absolute;
    top: 0px;
    left: 0px;
    display: flex;
    width: 33%;
    height: 100vh;
    overflow: hidden;
    user-select: none;
  }
  .item{
    width: 100%;
    display: flex;
    padding: 20px 20px;
    outline: 1px solid blue;
    position: absolute;
    top: 0px;
    left: 0px;
  }
  .item-inner{
    font-size: 40px;
    line-height: 1.2em;
    background-color: lightblue;
    padding: 20px;
    color: black;
  }

  .sss{
      display: flex;
  }
              
            
!

JS

              
                /*--------------------
Vars
--------------------*/
const $menu = document.querySelector('.grid')
const $items = document.querySelectorAll('.menu-item')
let menuHeight = $menu.clientHeight
let itemHeight = $items[0].clientHeight
let wrapHeight = $items.length * itemHeight

let scrollSpeed = 0
let oldScrollY = 0
let scrollY = 0
let y = 0


/*--------------------
Lerp
--------------------*/
const lerp = (v0, v1, t) => {
  return v0 * ( 1 - t ) + v1 * t
}


/*--------------------
Dispose
--------------------*/
const dispose = (scroll) => {
  gsap.set($items, {
    y: (i) => {
      return i * itemHeight + scroll
    },
    modifiers: {
      y: (y) => {
        const s = gsap.utils.wrap(-itemHeight, itemHeight + 5, parseInt(y))
        // const s = gsap.utils.wrap(-itemHeight, wrapHeight - itemHeight, parseInt(y))
        return `${s}px`
      }
    }
  })
} 
dispose(0)


/*--------------------
Wheel
--------------------*/
const handleMouseWheel = (e) => {
  scrollY -= e.deltaY  
}


/*--------------------
Touch
--------------------*/
let touchStart = 0
let touchY = 0
let isDragging = false
const handleTouchStart = (e) => {
  touchStart = e.clientY || e.touches[0].clientY
  isDragging = true
  $menu.classList.add('is-dragging')
}
const handleTouchMove = (e) => {
  if (!isDragging) return
  touchY = e.clientY || e.touches[0].clientY
  scrollY += (touchY - touchStart) * 2.5
  touchStart = touchY
}
const handleTouchEnd = () => {
  isDragging = false
  $menu.classList.remove('is-dragging')
}


/*--------------------
Listeners
--------------------*/
$menu.addEventListener('mousewheel', handleMouseWheel)

$menu.addEventListener('touchstart', handleTouchStart)
$menu.addEventListener('touchmove', handleTouchMove)
$menu.addEventListener('touchend', handleTouchEnd)

$menu.addEventListener('mousedown', handleTouchStart)
$menu.addEventListener('mousemove', handleTouchMove)
$menu.addEventListener('mouseleave', handleTouchEnd)
$menu.addEventListener('mouseup', handleTouchEnd)

$menu.addEventListener('selectstart', () => { return false })


/*--------------------
Resize
--------------------*/
window.addEventListener('resize', () => {
  menuHeight = $menu.clientHeight
  itemHeight = $items[0].clientHeight
  wrapHeight = $items.length * itemHeight
})


/*--------------------
Render
--------------------*/
const render = () => {
  requestAnimationFrame(render)
  y = lerp(y, scrollY, .1)
  dispose(y)
  
  scrollSpeed = y - oldScrollY
  oldScrollY = y
  
  gsap.to($items, {
    scale: 1 -  Math.min(100, Math.abs(scrollSpeed)) * .005,
    rotate: scrollSpeed * 0.2
  })
}
render()
              
            
!
999px

Console