Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

positions

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

positions - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

lib/includes.js

23

lib/positions.js
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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc