adjust-engine
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,7 @@ | ||
1.0.1 / 2015-08-19 | ||
================== | ||
* fix up math when top and left are set | ||
1.0.0 / 2010-01-03 | ||
@@ -2,0 +8,0 @@ ================== |
10
index.js
@@ -47,7 +47,11 @@ /** | ||
// calculate the target height and width | ||
var target_height = target_position.height || target_position.bottom - target_position.top | ||
var target_width = target_position.width || target_position.right - target_position.left | ||
// get the offsets | ||
var offset_y = target_position.top + target_position.bottom * target.y - attachment.y * height | ||
var offset_x = target_position.left + target_position.right * target.x - attachment.x * width | ||
var offset_y = target.y * target_height - attachment.y * height | ||
var offset_x = target.x * target_width - attachment.x * width | ||
// update the top and left with the offsets | ||
// update the position with the offsets | ||
var left = target_position.left + offset_x + offset.left | ||
@@ -54,0 +58,0 @@ var top = target_position.top + offset_y + offset.top |
{ | ||
"name": "adjust-engine", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "adjust an element relative to another element", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -15,26 +15,31 @@ | ||
### `adjust = Adjust(options)` | ||
##### `adjust = Adjust(options)` | ||
Initialize an adjustment. Supports the following options: | ||
- attachment <string>: Alignment point of the element you're moving. Supports CSS style adjustments. | ||
- **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) | ||
``` | ||
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. Here's some examples | ||
- **target** (string): Alignment point of the target (or host) element. Supports same CSS style adjustments as `attachment`. | ||
bottom: -10 | ||
left: 100 | ||
right: 50 | ||
top: -25 | ||
- **offset** (object): Specify an offset to apply to the attachment element. Here's some examples: | ||
- 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. | ||
``` | ||
bottom: -10 | ||
left: 100 | ||
right: 50 | ||
top: -25 | ||
``` | ||
### `adjust(attachment_position, target_position, [ viewport_position ])` | ||
- **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: | ||
@@ -41,0 +46,0 @@ |
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
5961
117
88