Sha256: 9dc4cb8a877caa7f8b855468b89ed761326de76ec61e1d7149e4668f515ee946

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

after = (ms, fn) -> setTimeout(fn, ms)

jQuery ($) ->
  # Detect 3D support

  prefix = 'moz'    if $.browser.mozilla
  prefix = 'webkit' if $.browser.webkit
  prefix = 'o'      if $.browser.opera
  prefix = 'ms'     if $.browser.msie

  detect3d = ->
    return true  if document.body.style.MozPerspective?
    return false unless window.matchMedia?

    result = matchMedia("all and (transform-3d)")
    return true if result.matches
    matchMedia("all and (-#{prefix}-transform-3d)").matches

  support3d = detect3d()
  $('body').addClass(if support3d then 'transform3d' else 'transform2d')

  # Open source corner animation

  if support3d
    corner    = $('.open-source')
    shadow    = corner.find('.shadow')
    translate = corner.find('.translate')
    rotator   = corner.find('.rotator')

    duration   = rotator.css('transition-duration')
    duration ||= rotator.css("-#{prefix}-transition-duration")
    duration   = parseFloat(duration) * 1000

    shadowing = ->
      if shadow.is(':animated')
        shadow.stop(true).animate(opacity: 0, (duration / 2), 'linear')
      else
        shadow.animate(opacity: 1, (duration / 2), 'linear').
               animate(opacity: 0, (duration / 2), 'linear')

    corner.mouseenter ->
      shadowing()
      after duration, ->
        translate.addClass('show') if corner.is(':hover')
    corner.mouseleave ->
      shadowing()
      translate.removeClass('show')

    # FF backface-visibility fix

    if $.browser.mozilla
      back = corner.find('.text, .border')
      corner.mouseenter ->
        back.stop(true).delay(duration / 2).hide(1)
      corner.mouseleave ->
        back.stop(true).delay(duration / 2).show(1)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tonic-0.0.6 template/assets/coffee/open_source.coffee
tonic-0.0.4 template/assets/coffee/open_source.coffee
tonic-0.0.3 template/assets/coffee/open_source.coffee
tonic-0.0.2 template/assets/coffee/open_source.coffee