summaryrefslogtreecommitdiffstats
path: root/afm-client/bower_components/tether/coffee/shift.coffee
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2016-01-28 16:30:12 +0100
committerFulup Ar Foll <fulup@iot.bzh>2016-01-28 16:30:12 +0100
commitbe83a8f382cf2fea98161bfd6d51719aacbf9aa9 (patch)
tree3fb02337f8d7d308ef7ca7818ecc3d3a6ee05d88 /afm-client/bower_components/tether/coffee/shift.coffee
parent1a4ed39bf86b2115eb0f1387d1e988462b492776 (diff)
Update JSON API
Diffstat (limited to 'afm-client/bower_components/tether/coffee/shift.coffee')
-rw-r--r--afm-client/bower_components/tether/coffee/shift.coffee27
1 files changed, 27 insertions, 0 deletions
diff --git a/afm-client/bower_components/tether/coffee/shift.coffee b/afm-client/bower_components/tether/coffee/shift.coffee
new file mode 100644
index 0000000..4dede41
--- /dev/null
+++ b/afm-client/bower_components/tether/coffee/shift.coffee
@@ -0,0 +1,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}