summaryrefslogtreecommitdiffstats
path: root/afm-client/bower_components/tether/coffee/shift.coffee
blob: 4dede411d2f522ed8125924e8295463d61a5743c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@Tether.modules.push
  position: ({top, left}) ->
    return unless @options.shift

    result = (val) ->
      if typeof val is 'function'
        val.call @, {top, left}
      else
        val

    shift = result @options.shift

    if typeof shift is 'string'
      shift = shift.split(' ')
      shift[1] or= shift[0]

      [shiftTop, shiftLeft] = shift

      shiftTop = parseFloat shiftTop, 10
      shiftLeft = parseFloat shiftLeft, 10
    else
      [shiftTop, shiftLeft] = [shift.top, shift.left]

    top += shiftTop
    left += shiftLeft

    {top, left}