0.3.0 • Published 8 years ago

@buzzalt/element-anchor v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 years ago

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.

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago