cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              -
  var sections = ['#1abc9c', '#2ecc71', '#3498db', '#9b59b6', '#34495e', '#f1c40f', '#e67e22', '#e74c3c']
  var pathTop = "M250,104.6C152.1,104.6,63.7,64.6,0,0l0,105.1h500V0C436.3,64.6,347.9,104.6,250,104.6z"
  var pathBottom = "M250,0.5c97.9,0,186.3,40,250,104.6V0H0v105.1C63.7,40.5,152.1,0.5,250,0.5z"

- for (var j = 0; j < 10; j++)
  - for (var i = 0; i < sections.length; i++)
    section(style="background-color:"+sections[i])
    if sections[i+1]
      div.curve
        svg.top(viewBox="0 0 500 105" PreserveAspectRatio="none")
          path(fill=sections[i+1] d=pathTop)
        svg.bottom(viewBox="0 0 500 105" PreserveAspectRatio="none")
          path(fill=sections[i] d=pathBottom)
.scroll
  strong
    |scroll
  svg(xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24")
    path(fill="currentColor" d="M12 2c3.309 0 6 2.691 6 6v8c0 3.309-2.691 6-6 6s-6-2.691-6-6v-8c0-3.309 2.691-6 6-6zm0-2c-4.418 0-8 3.582-8 8v8c0 4.418 3.582 8 8 8s8-3.582 8-8v-8c0-4.418-3.582-8-8-8zm0 9c-.829 0-1.5-.672-1.5-1.5s.671-1.5 1.5-1.5 1.5.672 1.5 1.5-.671 1.5-1.5 1.5z")
            
          
!
            
              body {
  --transform-top: 0;
  --transform-bottom: 0;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

section {
  height: 50vh;
}

.curve {
  position: absolute;
  z-index: 3;
  width: 100%;
  transform: translate3d(0,-50%,0);
  pointer-events: none;


  svg {
    display: block;
  }

  .top {
    transform: scale3d(1, 0, 1); // fallback
    transform: scale3d(1, var(--transform-top), 1);
    transform-origin: bottom;
  }

  .bottom {
    transform: scale3d(1, 0, 1); // fallback
    transform: scale3d(1, var(--transform-bottom), 1);
    transform-origin: top;
    margin-top: -1px; // Fix overlapping
  }
}

.scroll {
  color: white;
  position: fixed;
  top: 50%; left: 50%;
  z-index: 999;
  transform: translate(-50%,-50%);
  
  strong {
    display: block;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 0.5em;
    line-height: 2;
  }
  
  svg {
    display: block;
    margin: auto;
  }
}
            
          
!
            
              const brake = .5
const slowness = .85
const accelerator = (window.innerWidth + window.innerHeight) / 2
let   oldScrollY = 0
let   scaleY = 0

const updateCurve = () => {
  // Get new scroll
  const newScrollY = document.scrollingElement.scrollTop
  // Get difference between previous scroll position
  const deltaY = (newScrollY - oldScrollY) * brake
  // Remember current scroll position
  oldScrollY = newScrollY
  // Calculate new scale
  const newScale = deltaY / accelerator
  // Add new scale and slow it
  scaleY = (scaleY + newScale) * slowness
  // Update CSS vars
  setStyle('--transform-top', minmax(-scaleY, 0, 1))
  setStyle('--transform-bottom', minmax(scaleY, 0, 1))
  // Again
  requestAnimationFrame(updateCurve)
}

requestAnimationFrame(updateCurve)

const minmax = (val, min, max) => Math.max(min, Math.min(max, val))
const setStyle = (property, value) => document.body.style.setProperty(property, minmax(value, 0, 1).toFixed(4))

// Demo on load
$(document).ready(e => {
  $('html,body').animate({scrollTop: $(window).height()*2}, 500, () => {
    setTimeout(() => {
      $('html,body').animate({scrollTop: 0}, 500)
    }, 100)
  })
})
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console