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

viewprt

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewprt - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

2

dist/es/viewprt.js

@@ -1,2 +0,2 @@

function t(t,e){var i=this;this.container=t,this.observers=[],this.lastX=0,this.lastY=0;var o=!1,n=function(){o||(o=!0,requestAnimationFrame((function(){for(var t=i.observers,e=i.getState(),n=t.length;n--;)t[n].check(e);i.lastX=e.positionX,i.lastY=e.positionY,o=!1})))},s=e.handleScrollResize,r=this.handler=s?s(n):n,h=function(){(i.mutationObserver=new MutationObserver(n)).observe(document,{attributes:!0,childList:!0,subtree:!0})};addEventListener("scroll",r,!0),addEventListener("resize",r,!0),"loading"!==document.readyState?h():addEventListener("DOMContentLoaded",h)}function e(t){var e=~~t.offset||0;return this.offsetX=null!=t.offsetX?~~t.offsetX:e,this.offsetY=null!=t.offsetY?~~t.offsetY:e,this.container=t.container||document.body,this.once=!!t.once,this.observerCollection=t.observerCollection||o,this.activate()}function i(t){if(void 0===t&&(t={}),!(this instanceof i))return new i(t);this.viewports=new Map,this.handleScrollResize=t.handleScrollResize}t.prototype={getState:function(){var t,e,i,o,n=this.container,s=this.lastX,r=this.lastY;return n===document.body?(t=window.innerWidth,e=window.innerHeight,i=window.pageXOffset,o=window.pageYOffset):(t=n.offsetWidth,e=n.offsetHeight,i=n.scrollLeft,o=n.scrollTop),{width:t,height:e,positionX:i,positionY:o,directionX:s<i?"right":s>i?"left":"none",directionY:r<o?"down":r>o?"up":"none"}},destroy:function(){var t=this.handler,e=this.mutationObserver;removeEventListener("scroll",t),removeEventListener("resize",t),e&&e.disconnect()}},e.prototype={activate:function(){var e=this.container,i=this.observerCollection,o=i.viewports,n=o.get(e);n||(n=new t(e,i),o.set(e,n));var s=n.observers;return s.indexOf(this)<0&&s.push(this),n},destroy:function(){var t=this.container,e=this.observerCollection.viewports,i=e.get(t);if(i){var o=i.observers,n=o.indexOf(this);n>-1&&o.splice(n,1),o.length||(i.destroy(),e.delete(t))}}};var o=new i;function n(t){if(void 0===t&&(t={}),!(this instanceof n))return new n(t);this.onTop=t.onTop,this.onBottom=t.onBottom,this.onLeft=t.onLeft,this.onRight=t.onRight,this.onFit=t.onFit,this._wasTop=!0,this._wasBottom=!1,this._wasLeft=!0,this._wasRight=!1,this._wasFit=!1;var i=e.call(this,t);this.check(i.getState())}function s(t,i){if(void 0===i&&(i={}),!(this instanceof s))return new s(t,i);this.element=t,this.onEnter=i.onEnter,this.onExit=i.onExit,this._didEnter=!1;var o=e.call(this,i);r(t)&&this.check(o.getState())}function r(t){return t&&t.parentNode}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.check=function(t){var e=this,i=e.onTop,o=e.onBottom,n=e.onLeft,s=e.onRight,r=e.onFit,h=e._wasTop,a=e._wasBottom,c=e._wasLeft,l=e._wasRight,f=e._wasFit,d=e.container,p=e.offsetX,u=e.offsetY,v=e.once,w=d.scrollHeight,g=d.scrollWidth,b=t.width,m=t.height,y=t.positionX,_=t.positionY,E=_-u<=0,L=w>m&&m+_+u>=w,X=y-p<=0,Y=g>b&&b+y+p>=g,R=w<=m&&g<=b,O=!1;o&&!a&&L?o.call(this,d,t):i&&!h&&E?i.call(this,d,t):s&&!l&&Y?s.call(this,d,t):n&&!c&&X?n.call(this,d,t):r&&!f&&R?r.call(this,d,t):O=!0,v&&!O&&this.destroy(),this._wasTop=E,this._wasBottom=L,this._wasLeft=X,this._wasRight=Y,this._wasFit=R},s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.check=function(t){var e=this.container,i=this.onEnter,o=this.onExit,n=this.element,s=this.offsetX,h=this.offsetY,a=this.once,c=this._didEnter;if(!r(n))return this.destroy();var l=function(t,e,i,o,n){var s,r,h,a,c=t.getBoundingClientRect();if(!c.width||!c.height)return!1;var l=window.innerWidth,f=window.innerHeight,d=l;if(n===document.body)s=f,r=0,h=d,a=0;else{if(!(c.top<f&&c.bottom>0&&c.left<d&&c.right>0))return!1;var p=n.getBoundingClientRect();s=p.bottom,r=p.top,h=p.right,a=p.left}return c.top<s+i&&c.bottom>r-i&&c.left<h+e&&c.right>a-e}(n,s,h,0,e);!c&&l?(this._didEnter=!0,i&&(i.call(this,n,t),a&&this.destroy())):c&&!l&&(this._didEnter=!1,o&&(o.call(this,n,t),a&&this.destroy()))};export{s as ElementObserver,i as ObserverCollection,n as PositionObserver};
function t(t,e){var i=this;this.container=t,this.observers=[],this.lastX=0,this.lastY=0;var o=!1,n=function(){o||(o=!0,requestAnimationFrame((function(){for(var t=i.observers,e=i.getState(),n=t.length;n--;)t[n].check(e);i.lastX=e.positionX,i.lastY=e.positionY,o=!1})))},s=e.handleScrollResize,r=this.handler=s?s(n):n,h=function(){(i.mutationObserver=new MutationObserver(n)).observe(document,{attributes:!0,childList:!0,subtree:!0})},a={capture:!0,passive:!0};addEventListener("scroll",r,a),addEventListener("resize",r,a),"loading"!==document.readyState?h():addEventListener("DOMContentLoaded",h)}function e(t){var e=~~t.offset||0;return this.offsetX=null!=t.offsetX?~~t.offsetX:e,this.offsetY=null!=t.offsetY?~~t.offsetY:e,this.container=t.container||document.body,this.once=!!t.once,this.observerCollection=t.observerCollection||o,this.activate()}function i(t){if(void 0===t&&(t={}),!(this instanceof i))return new i(t);this.viewports=new Map,this.handleScrollResize=t.handleScrollResize}t.prototype={getState:function(){var t,e,i,o,n=this,s=n.container,r=n.lastX,h=n.lastY;return s===document.body?(t=window.innerWidth,e=window.innerHeight,i=window.pageXOffset,o=window.pageYOffset):(t=s.offsetWidth,e=s.offsetHeight,i=s.scrollLeft,o=s.scrollTop),{width:t,height:e,positionX:i,positionY:o,directionX:r<i?"right":r>i?"left":"none",directionY:h<o?"down":h>o?"up":"none"}},destroy:function(){var t=this.handler,e=this.mutationObserver;removeEventListener("scroll",t),removeEventListener("resize",t),e&&e.disconnect()}},e.prototype={activate:function(){var e=this.container,i=this.observerCollection,o=i.viewports,n=o.get(e);n||(n=new t(e,i),o.set(e,n));var s=n.observers;return s.indexOf(this)<0&&s.push(this),n},destroy:function(){var t=this.container,e=this.observerCollection.viewports,i=e.get(t);if(i){var o=i.observers,n=o.indexOf(this);n>-1&&o.splice(n,1),o.length||(i.destroy(),e.delete(t))}}};var o=new i;function n(t){if(void 0===t&&(t={}),!(this instanceof n))return new n(t);this.onTop=t.onTop,this.onBottom=t.onBottom,this.onLeft=t.onLeft,this.onRight=t.onRight,this.onFit=t.onFit,this._wasTop=!0,this._wasBottom=!1,this._wasLeft=!0,this._wasRight=!1,this._wasFit=!1;var i=e.call(this,t);this.check(i.getState())}function s(t,i){if(void 0===i&&(i={}),!(this instanceof s))return new s(t,i);this.element=t,this.onEnter=i.onEnter,this.onExit=i.onExit,this._didEnter=!1;var o=e.call(this,i);r(t)&&this.check(o.getState())}function r(t){return t&&t.parentNode}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.check=function(t){var e=this,i=e.onTop,o=e.onBottom,n=e.onLeft,s=e.onRight,r=e.onFit,h=e._wasTop,a=e._wasBottom,c=e._wasLeft,l=e._wasRight,f=e._wasFit,d=e.container,p=e.offsetX,u=e.offsetY,v=e.once,w=d.scrollHeight,g=d.scrollWidth,b=t.width,m=t.height,y=t.positionX,_=t.positionY,E=_-u<=0,L=w>m&&m+_+u>=w,X=y-p<=0,Y=g>b&&b+y+p>=g,R=w<=m&&g<=b,O=!1;o&&!a&&L?o.call(this,d,t):i&&!h&&E?i.call(this,d,t):s&&!l&&Y?s.call(this,d,t):n&&!c&&X?n.call(this,d,t):r&&!f&&R?r.call(this,d,t):O=!0,v&&!O&&this.destroy(),this._wasTop=E,this._wasBottom=L,this._wasLeft=X,this._wasRight=Y,this._wasFit=R},s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.check=function(t){var e=this,i=e.container,o=e.onEnter,n=e.onExit,s=e.element,h=e.offsetX,a=e.offsetY,c=e.once,l=e._didEnter;if(!r(s))return this.destroy();var f=function(t,e,i,o,n){var s,r,h,a,c=t.getBoundingClientRect();if(!c.width||!c.height)return!1;var l=window.innerWidth,f=window.innerHeight,d=l,p=0,u=0;if(n===document.body)s=f,r=u,h=d,a=p;else{if(!(c.top<f&&c.bottom>u&&c.left<d&&c.right>p))return!1;var v=n.getBoundingClientRect();s=v.bottom,r=v.top,h=v.right,a=v.left}return c.top<s+i&&c.bottom>r-i&&c.left<h+e&&c.right>a-e}(s,h,a,0,i);!l&&f?(this._didEnter=!0,o&&(o.call(this,s,t),c&&this.destroy())):l&&!f&&(this._didEnter=!1,n&&(n.call(this,s,t),c&&this.destroy()))};export{s as ElementObserver,i as ObserverCollection,n as PositionObserver};
//# sourceMappingURL=viewprt.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).viewprt={})}(this,(function(t){"use strict";function e(t,e){var i=this;this.container=t,this.observers=[],this.lastX=0,this.lastY=0;var o=!1,n=function(){o||(o=!0,requestAnimationFrame((function(){for(var t=i.observers,e=i.getState(),n=t.length;n--;)t[n].check(e);i.lastX=e.positionX,i.lastY=e.positionY,o=!1})))},s=e.handleScrollResize,r=this.handler=s?s(n):n,h=function(){(i.mutationObserver=new MutationObserver(n)).observe(document,{attributes:!0,childList:!0,subtree:!0})};addEventListener("scroll",r,!0),addEventListener("resize",r,!0),"loading"!==document.readyState?h():addEventListener("DOMContentLoaded",h)}function i(t){var e=~~t.offset||0;return this.offsetX=null!=t.offsetX?~~t.offsetX:e,this.offsetY=null!=t.offsetY?~~t.offsetY:e,this.container=t.container||document.body,this.once=!!t.once,this.observerCollection=t.observerCollection||n,this.activate()}function o(t){if(void 0===t&&(t={}),!(this instanceof o))return new o(t);this.viewports=new Map,this.handleScrollResize=t.handleScrollResize}e.prototype={getState:function(){var t,e,i,o,n=this.container,s=this.lastX,r=this.lastY;return n===document.body?(t=window.innerWidth,e=window.innerHeight,i=window.pageXOffset,o=window.pageYOffset):(t=n.offsetWidth,e=n.offsetHeight,i=n.scrollLeft,o=n.scrollTop),{width:t,height:e,positionX:i,positionY:o,directionX:s<i?"right":s>i?"left":"none",directionY:r<o?"down":r>o?"up":"none"}},destroy:function(){var t=this.handler,e=this.mutationObserver;removeEventListener("scroll",t),removeEventListener("resize",t),e&&e.disconnect()}},i.prototype={activate:function(){var t=this.container,i=this.observerCollection,o=i.viewports,n=o.get(t);n||(n=new e(t,i),o.set(t,n));var s=n.observers;return s.indexOf(this)<0&&s.push(this),n},destroy:function(){var t=this.container,e=this.observerCollection.viewports,i=e.get(t);if(i){var o=i.observers,n=o.indexOf(this);n>-1&&o.splice(n,1),o.length||(i.destroy(),e.delete(t))}}};var n=new o;function s(t){if(void 0===t&&(t={}),!(this instanceof s))return new s(t);this.onTop=t.onTop,this.onBottom=t.onBottom,this.onLeft=t.onLeft,this.onRight=t.onRight,this.onFit=t.onFit,this._wasTop=!0,this._wasBottom=!1,this._wasLeft=!0,this._wasRight=!1,this._wasFit=!1;var e=i.call(this,t);this.check(e.getState())}function r(t,e){if(void 0===e&&(e={}),!(this instanceof r))return new r(t,e);this.element=t,this.onEnter=e.onEnter,this.onExit=e.onExit,this._didEnter=!1;var o=i.call(this,e);h(t)&&this.check(o.getState())}function h(t){return t&&t.parentNode}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.check=function(t){var e=this,i=e.onTop,o=e.onBottom,n=e.onLeft,s=e.onRight,r=e.onFit,h=e._wasTop,a=e._wasBottom,c=e._wasLeft,f=e._wasRight,l=e._wasFit,d=e.container,p=e.offsetX,u=e.offsetY,v=e.once,w=d.scrollHeight,g=d.scrollWidth,b=t.width,m=t.height,y=t.positionX,_=t.positionY,E=_-u<=0,L=w>m&&m+_+u>=w,O=y-p<=0,X=g>b&&b+y+p>=g,Y=w<=m&&g<=b,R=!1;o&&!a&&L?o.call(this,d,t):i&&!h&&E?i.call(this,d,t):s&&!f&&X?s.call(this,d,t):n&&!c&&O?n.call(this,d,t):r&&!l&&Y?r.call(this,d,t):R=!0,v&&!R&&this.destroy(),this._wasTop=E,this._wasBottom=L,this._wasLeft=O,this._wasRight=X,this._wasFit=Y},r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.check=function(t){var e=this.container,i=this.onEnter,o=this.onExit,n=this.element,s=this.offsetX,r=this.offsetY,a=this.once,c=this._didEnter;if(!h(n))return this.destroy();var f=function(t,e,i,o,n){var s,r,h,a,c=t.getBoundingClientRect();if(!c.width||!c.height)return!1;var f=window.innerWidth,l=window.innerHeight,d=f;if(n===document.body)s=l,r=0,h=d,a=0;else{if(!(c.top<l&&c.bottom>0&&c.left<d&&c.right>0))return!1;var p=n.getBoundingClientRect();s=p.bottom,r=p.top,h=p.right,a=p.left}return c.top<s+i&&c.bottom>r-i&&c.left<h+e&&c.right>a-e}(n,s,r,0,e);!c&&f?(this._didEnter=!0,i&&(i.call(this,n,t),a&&this.destroy())):c&&!f&&(this._didEnter=!1,o&&(o.call(this,n,t),a&&this.destroy()))},t.ElementObserver=r,t.ObserverCollection=o,t.PositionObserver=s,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).viewprt={})}(this,(function(t){"use strict";function e(t,e){var o=this;this.container=t,this.observers=[],this.lastX=0,this.lastY=0;var i=!1,n=function(){i||(i=!0,requestAnimationFrame((function(){for(var t=o.observers,e=o.getState(),n=t.length;n--;)t[n].check(e);o.lastX=e.positionX,o.lastY=e.positionY,i=!1})))},s=e.handleScrollResize,r=this.handler=s?s(n):n,h=function(){(o.mutationObserver=new MutationObserver(n)).observe(document,{attributes:!0,childList:!0,subtree:!0})},a={capture:!0,passive:!0};addEventListener("scroll",r,a),addEventListener("resize",r,a),"loading"!==document.readyState?h():addEventListener("DOMContentLoaded",h)}function o(t){var e=~~t.offset||0;return this.offsetX=null!=t.offsetX?~~t.offsetX:e,this.offsetY=null!=t.offsetY?~~t.offsetY:e,this.container=t.container||document.body,this.once=!!t.once,this.observerCollection=t.observerCollection||n,this.activate()}function i(t){if(void 0===t&&(t={}),!(this instanceof i))return new i(t);this.viewports=new Map,this.handleScrollResize=t.handleScrollResize}e.prototype={getState:function(){var t,e,o,i,n=this,s=n.container,r=n.lastX,h=n.lastY;return s===document.body?(t=window.innerWidth,e=window.innerHeight,o=window.pageXOffset,i=window.pageYOffset):(t=s.offsetWidth,e=s.offsetHeight,o=s.scrollLeft,i=s.scrollTop),{width:t,height:e,positionX:o,positionY:i,directionX:r<o?"right":r>o?"left":"none",directionY:h<i?"down":h>i?"up":"none"}},destroy:function(){var t=this.handler,e=this.mutationObserver;removeEventListener("scroll",t),removeEventListener("resize",t),e&&e.disconnect()}},o.prototype={activate:function(){var t=this.container,o=this.observerCollection,i=o.viewports,n=i.get(t);n||(n=new e(t,o),i.set(t,n));var s=n.observers;return s.indexOf(this)<0&&s.push(this),n},destroy:function(){var t=this.container,e=this.observerCollection.viewports,o=e.get(t);if(o){var i=o.observers,n=i.indexOf(this);n>-1&&i.splice(n,1),i.length||(o.destroy(),e.delete(t))}}};var n=new i;function s(t){if(void 0===t&&(t={}),!(this instanceof s))return new s(t);this.onTop=t.onTop,this.onBottom=t.onBottom,this.onLeft=t.onLeft,this.onRight=t.onRight,this.onFit=t.onFit,this._wasTop=!0,this._wasBottom=!1,this._wasLeft=!0,this._wasRight=!1,this._wasFit=!1;var e=o.call(this,t);this.check(e.getState())}function r(t,e){if(void 0===e&&(e={}),!(this instanceof r))return new r(t,e);this.element=t,this.onEnter=e.onEnter,this.onExit=e.onExit,this._didEnter=!1;var i=o.call(this,e);h(t)&&this.check(i.getState())}function h(t){return t&&t.parentNode}s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.check=function(t){var e=this,o=e.onTop,i=e.onBottom,n=e.onLeft,s=e.onRight,r=e.onFit,h=e._wasTop,a=e._wasBottom,c=e._wasLeft,f=e._wasRight,l=e._wasFit,d=e.container,p=e.offsetX,u=e.offsetY,v=e.once,w=d.scrollHeight,g=d.scrollWidth,b=t.width,y=t.height,m=t.positionX,_=t.positionY,E=_-u<=0,L=w>y&&y+_+u>=w,O=m-p<=0,X=g>b&&b+m+p>=g,Y=w<=y&&g<=b,R=!1;i&&!a&&L?i.call(this,d,t):o&&!h&&E?o.call(this,d,t):s&&!f&&X?s.call(this,d,t):n&&!c&&O?n.call(this,d,t):r&&!l&&Y?r.call(this,d,t):R=!0,v&&!R&&this.destroy(),this._wasTop=E,this._wasBottom=L,this._wasLeft=O,this._wasRight=X,this._wasFit=Y},r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.prototype.check=function(t){var e=this,o=e.container,i=e.onEnter,n=e.onExit,s=e.element,r=e.offsetX,a=e.offsetY,c=e.once,f=e._didEnter;if(!h(s))return this.destroy();var l=function(t,e,o,i,n){var s,r,h,a,c=t.getBoundingClientRect();if(!c.width||!c.height)return!1;var f=window.innerWidth,l=window.innerHeight,d=f,p=0,u=0;if(n===document.body)s=l,r=u,h=d,a=p;else{if(!(c.top<l&&c.bottom>u&&c.left<d&&c.right>p))return!1;var v=n.getBoundingClientRect();s=v.bottom,r=v.top,h=v.right,a=v.left}return c.top<s+o&&c.bottom>r-o&&c.left<h+e&&c.right>a-e}(s,r,a,0,o);!f&&l?(this._didEnter=!0,i&&(i.call(this,s,t),c&&this.destroy())):f&&!l&&(this._didEnter=!1,n&&(n.call(this,s,t),c&&this.destroy()))},t.ElementObserver=r,t.ObserverCollection=i,t.PositionObserver=s,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=viewprt.js.map
{
"name": "viewprt",
"version": "4.1.0",
"version": "4.2.0",
"description": "A tiny, dependency-free, high performance viewport position & intersection observation tool",

@@ -34,9 +34,9 @@ "author": "Garth Poitras <garth22@gmail.com>",

"devDependencies": {
"flt": "^0.22.0",
"puppeteer": "^2.1.1",
"rollup": "^2.1.0",
"flt": "^0.34.0",
"puppeteer": "^5.4.1",
"rollup": "^2.32.1",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.3.0"
"rollup-plugin-terser": "^7.0.2"
}
}

@@ -60,3 +60,3 @@ # viewprt [![Build Status](https://travis-ci.org/gpoitch/viewprt.svg)](https://travis-ci.org/gpoitch/viewprt)

positionX: 0,
positionY: 2000
positionY: 2000,
directionY: "down",

@@ -63,0 +63,0 @@ directionX: "none"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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