Comparing version 1.0.1 to 1.1.0
var getOffset = require('./offset') | ||
var getSize = require('./size') | ||
var getAdjustment = require('./adjustment') | ||
var includes = require('./includes') | ||
module.exports = function positions (el, my, target, their) { | ||
my = my.split(' ') | ||
their = their.split(' ') | ||
var mySize = getSize(el) | ||
var theirSize = getSize(target) | ||
var theirOffset = getOffset(target) | ||
var myVertical = my[0] | ||
var myHorizontal = my[1] | ||
var theirVertical = their[0] | ||
var theirHorizontal = their[1] | ||
var adjustment = getAdjustment(el) | ||
@@ -19,23 +14,23 @@ var left = theirOffset.left - adjustment.left | ||
if (theirHorizontal === 'right') { | ||
if (includes(their, 'right')) { | ||
left += theirSize.width | ||
} else if (theirHorizontal === 'center') { | ||
} else if (!includes(their, 'left')) { | ||
left += theirSize.width / 2 | ||
} | ||
if (theirVertical === 'bottom') { | ||
if (includes(their, 'bottom')) { | ||
top += theirSize.height | ||
} else if (theirVertical === 'center') { | ||
} else if (!includes(their, 'top')) { | ||
top += theirSize.height / 2 | ||
} | ||
if (myHorizontal === 'right') { | ||
if (includes(my, 'right')) { | ||
left -= mySize.width | ||
} else if (myHorizontal === 'center') { | ||
} else if (!includes(my, 'left')) { | ||
left -= mySize.width / 2 | ||
} | ||
if (myVertical === 'bottom') { | ||
if (includes(my, 'bottom')) { | ||
top -= mySize.height | ||
} else if (myVertical === 'center') { | ||
} else if (!includes(my, 'top')) { | ||
top -= mySize.height / 2 | ||
@@ -42,0 +37,0 @@ } |
{ | ||
"name": "positions", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A small, dependency free dom element positioning lib inspired by jquery-ui/position", | ||
@@ -5,0 +5,0 @@ "main": "lib/positions.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23995
17
647