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

adjust-engine

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adjust-engine

adjust an element relative to another element

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

adjust-engine

Position an element relative to another element. This repository is the workhorse behind adjust.

Installation

npm install adjust-engine

API

adjust = Adjust(options)

Initialize an adjustment. Supports the following options:

  • attachment (string): Alignment point of the element you're moving. Supports CSS style adjustments. Here are some possibilities:
left top
right bottom
center middle
10% 16% (x y)
  • target (string): Alignment point of the target (or host) element. Supports same CSS style adjustments as attachment.

  • offset (object): Specify an offset to apply to the attachment element:

x: 10
y: -10
  • flip (boolean): Defaults to true. Automatically flip the element if the adjustment causes the attachment to be out of viewport. You should specify a viewport_position for flip to work properly.
adjust(attachment_position, target_position, [ viewport_position ])

Get a position of where the attachment should be. Here's a full example:

var adjust = Adjust({
  attachment: 'center middle',
  target: 'center middle'
});

var attachment = {
  height: 50,
  width: 50
}

var target = {
  top: 0,
  left: 0,
  right: 100,
  bottom: 100
}

var position = adjust(attachment, target)
assert.deepEqual(position, {
  top: 25,
  left: 25,
  width: 50,
  height: 50,
  right: 75,
  bottom: 75
})

Tests

make test

TODO

  • memoize

License

MIT

Keywords

FAQs

Package last updated on 31 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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