@buzzalt/element-anchor v0.3.0
element-anchor
The element anchor provides API for positioning along the bounding rect of a target element. Works with SVG and HTML elements.
Sample usage
import {anchor} from '@buzzalt/element-anchor';
const instance = anchor('right').offset(10);
const { x, y } = instance.absolute(target);
anchor(config: string|string[]|number|number[]|mixed)
Accepts one or two values of the following types
- alias - top, right, bottom, left, center
- percent - 0 - 100% (can be negative and not limited by 100%)
- number (can be negative)
Instance methods
anchor.x([x]: string|number)
If no value provided, returns the current x
value.
anchor.y([y]: string|number)
If no value provided, returns the current y
value.
anchor.offset([offset]: string|string[]|number|number[]|mixed)
If no value provided, returns the current offset.
anchor.target([target]: string|SVGElement|HTMLElement)
If no value provided, returns the current target.
anchor.relative([target]: SVGElement|HTMLElement)
If no value provided, uses the current target.
anchor.absolute([target]: SVGElement|HTMLElement)
If no value provided, uses the current target.
See the demo here.
License: Apache 2.0.