UNPKG

javascript-inviewport

Version:

A simple to use, light weight, zero dependency, pure JavaScript and TypeScript ready plugin that uses the intersection observer to determine whether an element has entered within the windows viewport.

2 lines 1.23 kB
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("javascript-inviewport",[],r):"object"==typeof exports?exports["javascript-inviewport"]=r():e["javascript-inviewport"]=r()}(this,(function(){return(()=>{"use strict";var e={d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};function t(e,r,t){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if("IntersectionObserver"in window&&e){var n=o&&o.root?o.root:null,i=o&&o.rootMargin?o.rootMargin:"0px",a={root:n,rootMargin:i,threshold:Array.isArray(r)&&r.length>0||r>=0&&r<=1?r:.5},s=new IntersectionObserver((function(e,r){e.forEach((function(e){e.intersectionRatio>0&&(Array.isArray(t)?(t[0](),1===t.length&&r.unobserve(e.target)):t()),!1===e.isIntersecting&&Array.isArray(t)&&"function"==typeof t[1]&&t[1]()}))}),a);s.observe(e)}}return e.r(r),e.d(r,{default:()=>t}),r})()})); //# sourceMappingURL=inviewport.min.js.map