1.4.2 • Published 6 months ago

detect-element-overflow v1.4.2

Weekly downloads
81,688
License
MIT
Repository
github
Last release
6 months ago

npm downloads CI

Detect-Element-Overflow

A function that tells you whether a given element is overflowing its container or not. Useful for creating dropdowns and tooltips.

tl;dr

  • Install by executing npm install detect-element-overflow or yarn add detect-element-overflow.
  • Import by adding import detectElementOverflow from 'detect-element-overflow'.
  • Do stuff with it!
    const collisions = detectElementOverflow(child, parent);

User guide

Detect-Element-Overflow returns an object with getter functions described below.

Attribute nameDescriptionExample values
collidedTopWhether or not the child element collided with the top parent's border.true
collidedBottomWhether or not the child element collided with the bottom parent's border.true
collidedLeftWhether or not the child element collided with the left parent's border.true
collidedRightWhether or not the child element collided with the right parent's border.true
overflowTopHow many pixels of the child have crossed the top parent's border. Negative values specify how many pixels are between the child and the top parent's border.20, -15
overflowBottomHow many pixels of the child have crossed the bottom parent's border. Negative values specify how many pixels are between the child and the bottom parent's border.20, -15
overflowLeftHow many pixels of the child have crossed the left parent's border. Negative values specify how many pixels are between the child and the left parent's border.20, -15
overflowRightHow many pixels of the child have crossed the right parent's border. Negative values specify how many pixels are between the child and the right parent's border.20, -15

License

The MIT License.

Author

1.4.2

6 months ago

1.4.1

11 months ago

1.4.0

11 months ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

4 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.1-alpha

7 years ago