1.0.1 • Published 6 years ago

ringside v1.0.1

Weekly downloads
534
License
MIT
Repository
github
Last release
6 years ago

ringside CircleCI

A library that determines the fit and positioning of a rectangle relative to inner and outer bounds.

Installation

npm install ringside

Usage

Here's how you might generate the positioning for a tooltip:

import Ringside from 'ringside';

// define our target tooltip size
const tooltipSize = {
  height: 100,
  width: 200
};

// grab our target element and its container
const container = document.querySelector('.container');
const target = container.querySelector('.target');

const ringside = new Ringside(
  target.getBoundingClientRect(),     // target bounds
  container.getBoundingClientRect(),  // container bounds
  tooltipSize.height,
  tooltipSize.width
);

// select all positions that will fit
const possiblePositions = ringside
  .positions()
  .filter(position => position.fits);

// select a position from those that fit
const [position] = possiblePositions;

// and use it!
const tooltipPosition = {
  top: position.top,
  left: position.left,
  height: tooltipSize.height,
  width: tooltipSize.width
};

Development

# install packages
npm install

# run the storybook server
npm run storybook

# run tests
npm test
1.0.1

6 years ago

1.0.0

6 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago