Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

element-overlap

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-overlap - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "element-overlap",
"version": "0.0.2",
"version": "0.0.3",
"description": "Trigger an callback when two DOM elements overlap",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

# element-overlap
Trigger an callback when two DOM elements overlap.
Trigger an callback when two DOM elements overlap.
## Usage Example
```js
// For ES6:
import listenForOverlap from 'element-overlap';
// ...or for CommonJS:
var listenForOverlap = require('element-overlap').listenForOverlap;
listenForOverlap(
'#element1', '#element2',
function() {
alert('The elements have overlapped!');
}
);
```
## API and Options
### `void listenForOverlap(element1, element2, callback, options))`
The main method to set up a listener for the overlap. Will call `callback` when the elements are
overlapping according to the value `options.requiredIntersection`.
#### Arguments
##### `string` or `HTMLElement` :: **`element1`** - required
The first of the two elements to compare. This can either be a [CSS selector string](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_Started/Selectors)
or a reference to a DOM element (eg: the result of `getElementById` or `querySelector`)

@@ -33,2 +33,3 @@ import isString from 'is-string';

* @property {overlapTypes} requiredIntersection
* @property {*} callbackData
*/

@@ -82,7 +83,7 @@

case overlapTypes.intersect:
callback();
callback(options.callbackData);
break;
case overlapTypes.contain:
if (doesElementContainElement(element2, element1)) {
callback();
callback(options.callbackData);
}

@@ -92,3 +93,3 @@ break;

if (doesElementContainElement(element1, element2)) {
callback();
callback(options.callbackData);
}

@@ -95,0 +96,0 @@ break;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc