JavaScript

Take Control of Scroll Event

Take Control of Scroll Event, in order to add tweens:

## prevent keyboard triggered scrolling
keys = [37, 38, 39, 40, 32, 33, 34, 35, 36] # left: 37, up: 38, right: 39, down: 40, spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
$(document).on 'keydown', (e) =>
  for key in keys
    do e.preventDefault if e.keyCode == key

## take control of mousewheel scrolling
scroll = y: 0
$(document).on 'mousewheel', (e) =>
  e.preventDefault()
  TweenMax.to scroll, 0.55,
    y: window.scrollY - e.originalEvent.wheelDelta
    ease: Power3.easeOut
    onUpdate: => window.scroll 0, scroll.y
      
$(document).on 'scroll', (e) =>
  # do things

To see it in action: Link.

Standard