kaanersoy / did-i-see

A lightweight function that executes callback when we see specific DOM elements.

Home Page:https://did-i-see.vercel.app/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

did-i-see

A lightweight function that executes callback when we see specific DOM elements.

Built with IntersectionObserver.

đź”´ Demo: https://did-i-see.vercel.app/demo

Example Usage

<!-- It will inject the didISee to your window -->
<script src="https://did-i-see.vercel.app/index.js">
const options = {
  once: true,
  ...
};

window.didISee(
  ".element",
  ({ data }) => {
    console.log("I saw the element", data.target);
  },
  options
);
Arguments required
query query for selecting DOM elements true
callback({ data }) callback that will be fired when element in viewport true
options options of didISee (see options down below for more information) false
Options type default
once if it is true callback will be fired only one time for each element false
onlyEntrance if it is false callback will be fired when element is entering the screen and leaving the screen true
perc percentage of element that callback will be fired 0.5
root root element for scrolling area null

About

A lightweight function that executes callback when we see specific DOM elements.

https://did-i-see.vercel.app/demo

License:MIT License


Languages

Language:JavaScript 100.0%