Giter Site home page Giter Site logo

wojtekmaj / detect-element-overflow Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 10.0 3.22 MB

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

License: MIT License

TypeScript 100.00%
collision collision-detection position

detect-element-overflow's Introduction

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 name Description Example values
collidedTop Whether or not the child element collided with the top parent's border. true
collidedBottom Whether or not the child element collided with the bottom parent's border. true
collidedLeft Whether or not the child element collided with the left parent's border. true
collidedRight Whether or not the child element collided with the right parent's border. true
overflowTop How 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
overflowBottom How 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
overflowLeft How 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
overflowRight How 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

Wojciech Maj Wojciech Maj

detect-element-overflow's People

Contributors

dependabot[bot] avatar svish avatar wojtekmaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

detect-element-overflow's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.