css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              #scroll scroll me
#swipeme
  #div1
  #div2
  #div3
            
          
!
            
              html, body 
  margin: 0 auto
  padding: 0
  overflow: hidden

%extenddivs 
  width: 100vw
  height: 100vh
  transition: 0.5s ease-in-out

#scroll
  position: fixed
  color: white
  top: 50%
  transform: translateY(-50%)
  text-align: center
  width: 100%
  font-size: 60px
  text-transform: uppercase
  
#swipeme
  width: 100%
  height: 100vh
  text-align: center
  overflow: hidden
  
  #div1
    @extend %extenddivs
    background-color: #263238
    
#div2
  @extend %extenddivs
  background-color: #37474F
  
#div3
  @extend %extenddivs
  background-color: #455A64
            
          
!
            
              #variables
moved = '1'
#if its moved anywhere
dOne = document.getElementById('div1')
#swipe manipulation

iswiped = (el, func) ->
  d_s = new Object
  d_s.sX = 0
  d_s.sY = 0
  d_s.eX = 0
  d_s.eY = 0
  minX = 20
  #min x swipe for horizontal swipe
  maxX = 40
  #max x difference for vertical swipe
  minY = 40
  #min y swipe for vertical swipe
  maxY = 50
  #max y difference for horizontal swipe
  dir = ''
  ele = document.getElementById(el)
  ele.addEventListener 'touchstart', ((e) ->
    t = e.touches[0]
    d_s.sX = t.screenX
    d_s.sY = t.screenY
    return
  ), false
  ele.addEventListener 'touchmove', ((e) ->
    e.preventDefault()
    t = e.touches[0]
    d_s.eX = t.screenX
    d_s.eY = t.screenY
    return
  ), false
  ele.addEventListener 'touchend', ((e) ->
    #horizontal detection needed in order to work
    if (d_s.eX - minX > d_s.sX or d_s.eX + minX < d_s.sX) and d_s.eY < d_s.sY + maxY and d_s.sY > d_s.eY - maxY
      if d_s.eX > d_s.sX
        dir = 'r'
      else
        dir = 'l'
    #vertical detection
    if (d_s.eY - minY > d_s.sY or d_s.eY + minY < d_s.sY) and d_s.eX < d_s.sX + maxX and d_s.sX > d_s.eX - maxX
      if d_s.eY > d_s.sY
        dir = 'd'
      else
        dir = 'u'
    if dir != ''
      if typeof func == 'function'
        func el, dir
    dir = ''
    return
  ), false
  return

myfunction = (el, d) ->
  elm = el
  dir = d
  if dir == 'u' or dir == 'r' #up
    up()
  else #down
    down()
  return 

iswiped 'swipeme', myfunction 

#scroll wheel manipulation

window.addEventListener 'wheel', (e) ->
    #TODO add delay
  if e.deltaY < 0
    #scroll wheel up
    down()
  if e.deltaY > 0
    #scroll wheel down
    up()
  return

#arrow key manipulation

document.onkeydown = (e) ->
  switch e.keyCode #keyCode is depreciated idc tho
    when 38 #up
      down() #this makes sence in my head
    when 40 #down
      up() #this makes sence in my head
  return



#up and down functions

up = ->
  if moved == '1'
    dOne.style.marginTop = '-100vh'
    moved = '12'
    setTimeout(moved12, 1000)
  else if moved == '2'
    dOne.style.marginTop = '-200vh'
    moved = '13'
    setTimeout(moved13, 1000)
  return

down = ->
  if moved == '3'
    dOne.style.marginTop = '-100vh'
    moved = '12'
    setTimeout(moved12, 1000)
  else if moved == '2'
    dOne.style.marginTop = '0vh'
    moved = '11'
    setTimeout(moved11, 1000)
  return

moved11 = ->
  moved = '1'
  
moved12 = ->
  moved = '2'
  
moved13 = ->
  moved = '3'
            
          
!
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