Sha256: af4cec1f434c29b8e5ce45d65c69784a68acc9135d87324401cbb3f6d22f512b

Contents?: true

Size: 432 Bytes

Versions: 13

Compression:

Stored size: 432 Bytes

Contents

#= require partystreusel/namespace
Partystreusel.scrollTo = (x, relativeOffset = 0) ->
  if typeof x == 'object' && !(x instanceof $)
    # expect this is a hash and link is defined
    x = $("a[name=#{JSON.stringify(x.link)}]")

  if typeof x == 'string'
    x = $(x)
  if typeof x != 'number'
    x = x.offset()?.top

  return false unless x?

  x = Math.round(x) + relativeOffset
  $("html,body").animate({scrollTop: x}, 'slow')

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
partystreusel-2.0.0 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.2.0 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.1.1 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.1.0 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.1.0pre2 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.1.0pre1 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.8 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.7 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.6 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.5 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.4 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.3 app/assets/javascripts/partystreusel/scroll_to.js.coffee
partystreusel-1.0.2 app/assets/javascripts/partystreusel/scroll_to.js.coffee