Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jquery whole page/window slider
  2. step = (id) ->
  3.   width = $(window).width()
  4.   dir = 1
  5.   dir = -1  if id < curId
  6.   curId = id
  7.   $(".boxDisplay").animate
  8.     left: -1 * dir * width
  9.   , 500, "swing", ->
  10.     $(this).css "left", 0
  11.     $(this).removeClass "boxDisplay"
  12.     next = $(".box:eq(" + (id - 1) + ")")
  13.     next.addClass "boxDisplay"
  14.     boxPosition()
  15.     next.css "left", dir * width
  16.     next.animate
  17.       left: 0
  18.     , 500, "swing"
  19. animate = ->
  20.   i = 0
  21.   $(".box").animate(
  22.     left: -50
  23.   , 10).animate(
  24.     left: 0
  25.   , 50).animate(
  26.     left: 50
  27.   , 10).animate(
  28.     left: 0
  29.   , 50).animate(
  30.     left: -25
  31.   , 10).animate(
  32.     left: 0
  33.   , 50).animate(
  34.     left: 25
  35.   , 10).animate(
  36.     left: 0
  37.   , 50).animate
  38.     left: 0
  39.   , 800
  40. boxPosition = ->
  41.   height = $(".boxDisplay").height()
  42.   $(".box").css "margin-top", ($(window).height() / 2) - (height / 2)
  43.  
  44. $(document).ready ->
  45.   boxPosition()