diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-22 19:19:26 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-22 19:19:26 +0100 |
| commit | d42c8b528eb595101954f478e0024e3f079f6fbf (patch) | |
| tree | 61a528cf94f1f6941f4683ae8736a4a0135c035e /templates/assets/tether/src/js/shift.js | |
| download | minionlivesmatter-d42c8b528eb595101954f478e0024e3f079f6fbf.tar.gz minionlivesmatter-d42c8b528eb595101954f478e0024e3f079f6fbf.zip | |
first implementation of fun stats site
Diffstat (limited to 'templates/assets/tether/src/js/shift.js')
| -rw-r--r-- | templates/assets/tether/src/js/shift.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/templates/assets/tether/src/js/shift.js b/templates/assets/tether/src/js/shift.js new file mode 100644 index 0000000..ecc872d --- /dev/null +++ b/templates/assets/tether/src/js/shift.js @@ -0,0 +1,32 @@ +/* globals TetherBase */ + +TetherBase.modules.push({ + position({top, left}) { + if (!this.options.shift) { + return; + } + + let shift = this.options.shift; + if (typeof this.options.shift === 'function') { + shift = this.options.shift.call(this, {top, left}); + } + + let shiftTop, shiftLeft; + if (typeof shift === 'string') { + shift = shift.split(' '); + shift[1] = shift[1] || shift[0]; + + ([shiftTop, shiftLeft] = shift); + + shiftTop = parseFloat(shiftTop, 10); + shiftLeft = parseFloat(shiftLeft, 10); + } else { + ([shiftTop, shiftLeft] = [shift.top, shift.left]); + } + + top += shiftTop; + left += shiftLeft; + + return {top, left}; + } +}); |
