3.0.1 • Published 4 years ago

tackjs v3.0.1

Weekly downloads
97
License
MIT
Repository
github
Last release
4 years ago

tackjs

Tiny utility to position an element absolutely in relation to another element. 500b gzipped.

What's this for? Think popovers, modals, tooltips, scroll-jacking, etc.

Install

npm i tackjs --save

Usage

Usage is very straightfoward. Think, "pin element to target at the top":

import tack from 'tackjs'

const element = document.querySelector('...')
const target = document.querySelector('...')

const pin = tack(element, target, 'top')

To update the position – say after the window resizes – use update:

pin.update()

If you need to un-pin and remove all styles:

pin.destroy()

But don't worry! It can be re-pinned as well:

pin.update()

N.B. tackjs also adds an .is-tacked class to all pinned elements.

Alignment

Tack supports the following coordinates relative to the passed target element:

  • top
  • bottom
  • left
  • right
  • topLeft
  • topRight
  • bottomLeft
  • bottomRight

License

MIT License © Eric Bailey

3.0.1

4 years ago

3.0.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago