Socket
Socket
Sign inDemoInstall

in-view

Package Overview
Dependencies
1
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

2

dist/in-view.min.js

@@ -6,2 +6,2 @@ /*!

*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.inView=e():t.inView=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(3),o=r(i);t.exports=o["default"]},function(t,e){"use strict";function n(t,e){var n=t.getBoundingClientRect(),r=n.top,i=n.right,o=n.bottom,u=n.left,f={t:o,r:window.innerWidth-u,b:window.innerHeight-r,l:i};return f.t>e.top&&f.r>e.right&&f.b>e.bottom&&f.l>e.left}Object.defineProperty(e,"__esModule",{value:!0}),e.inViewport=n},function(t,e){function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(9),o=r(i),u=n(4),f=r(u),c=n(1),s=function(){var t=100,e=["scroll","resize","load"],n={history:[]},r={},i=(0,o["default"])(function(){n.history.forEach(function(t){n[t].check(r)})},t);e.forEach(function(t){return addEventListener(t,i)}),window.MutationObserver&&new MutationObserver(i).observe(document.body,{attributes:!0,childList:!0,subtree:!0});var u=function(t){if("string"==typeof t){var e=[].slice.call(document.querySelectorAll(t));return n.history.indexOf(t)>-1?n[t].elements=e:(n[t]=(0,f["default"])(e),n.history.push(t)),n[t]}};return u.offset=function(t){var e=function(t){return"number"==typeof t};return["top","right","bottom","left"].forEach(e(t)?function(e){return r[e]=t}:function(n){return e(t[n])?r[n]=t[n]:null}),r},u.is=c.inViewport,u.offset(0),u};e["default"]=s()},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=n(1),u=function(){function t(e){r(this,t),this.current=[],this.elements=e,this.handlers={enter:[],exit:[]},this.singles={enter:[],exit:[]}}return i(t,[{key:"check",value:function(t){var e=this;return this.elements.forEach(function(n){var r=(0,o.inViewport)(n,t),i=e.current.indexOf(n),u=i>-1,f=r&&!u,c=!r&&u;f&&(e.current.push(n),e.emit("enter",n)),c&&(e.current.splice(i,1),e.emit("exit",n))}),this}},{key:"on",value:function(t,e){return this.handlers[t].push(e),this}},{key:"once",value:function(t,e){return this.singles[t].unshift(e),this}},{key:"emit",value:function(t,e){for(;this.singles[t].length;)this.singles[t].pop()(e);for(var n=this.handlers[t].length;--n>-1;)this.handlers[t][n](e);return this}}]),t}();e["default"]=function(t){return new u(t)}},function(t,e){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(e,function(){return this}())},function(t,e,n){var r=n(5),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){function r(t,e,n){function r(e){var n=m,r=x;return m=x=void 0,E=e,w=t.apply(r,n)}function a(t){return E=t,j=setTimeout(h,e),_?r(t):w}function l(t){var n=t-O,r=t-E,i=e-n;return M?s(i,g-r):i}function d(t){var n=t-O,r=t-E;return void 0===O||n>=e||n<0||M&&r>=g}function h(){var t=o();return d(t)?p(t):void(j=setTimeout(h,l(t)))}function p(t){return j=void 0,T&&m?r(t):(m=x=void 0,w)}function v(){void 0!==j&&clearTimeout(j),E=0,m=O=x=j=void 0}function y(){return void 0===j?w:p(o())}function b(){var t=o(),n=d(t);if(m=arguments,x=this,O=t,n){if(void 0===j)return a(O);if(M)return j=setTimeout(h,e),r(O)}return void 0===j&&(j=setTimeout(h,e)),w}var m,x,g,w,j,O,E=0,_=!1,M=!1,T=!0;if("function"!=typeof t)throw new TypeError(f);return e=u(e)||0,i(n)&&(_=!!n.leading,M="maxWait"in n,g=M?c(u(n.maxWait)||0,e):g,T="trailing"in n?!!n.trailing:T),b.cancel=v,b.flush=y,b}var i=n(2),o=n(8),u=n(10),f="Expected a function",c=Math.max,s=Math.min;t.exports=r},function(t,e,n){var r=n(6),i=function(){return r.Date.now()};t.exports=i},function(t,e,n){function r(t,e,n){var r=!0,f=!0;if("function"!=typeof t)throw new TypeError(u);return o(n)&&(r="leading"in n?!!n.leading:r,f="trailing"in n?!!n.trailing:f),i(t,e,{leading:r,maxWait:e,trailing:f})}var i=n(7),o=n(2),u="Expected a function";t.exports=r},function(t,e){function n(t){return t}t.exports=n}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.inView=e():t.inView=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(3),o=r(i);t.exports=o["default"]},function(t,e){"use strict";function n(t,e){var n=t.getBoundingClientRect(),r=n.top,i=n.right,o=n.bottom,u=n.left,f={t:o,r:window.innerWidth-u,b:window.innerHeight-r,l:i};return f.t>e.top&&f.r>e.right&&f.b>e.bottom&&f.l>e.left}Object.defineProperty(e,"__esModule",{value:!0}),e.inViewport=n},function(t,e){function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(9),o=r(i),u=n(4),f=r(u),c=n(1),s=function(){var t=100,e=["scroll","resize","load"],n={history:[]},r={},i=(0,o["default"])(function(){n.history.forEach(function(t){n[t].check()})},t);e.forEach(function(t){return addEventListener(t,i)}),window.MutationObserver&&new MutationObserver(i).observe(document.body,{attributes:!0,childList:!0,subtree:!0});var u=function(t){if("string"==typeof t){var e=[].slice.call(document.querySelectorAll(t));return n.history.indexOf(t)>-1?n[t].elements=e:(n[t]=(0,f["default"])(e,r),n.history.push(t)),n[t]}};return u.offset=function(t){var e=function(t){return"number"==typeof t};return["top","right","bottom","left"].forEach(e(t)?function(e){return r[e]=t}:function(n){return e(t[n])?r[n]=t[n]:null}),r},u.is=function(t){return(0,c.inViewport)(t,r)},u.offset(0),u};e["default"]=s()},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=n(1),u=function(){function t(e,n){r(this,t),this.offset=n,this.current=[],this.elements=e,this.handlers={enter:[],exit:[]},this.singles={enter:[],exit:[]}}return i(t,[{key:"check",value:function(){var t=this;return this.elements.forEach(function(e){var n=(0,o.inViewport)(e,t.offset),r=t.current.indexOf(e),i=r>-1,u=n&&!i,f=!n&&i;u&&(t.current.push(e),t.emit("enter",e)),f&&(t.current.splice(r,1),t.emit("exit",e))}),this}},{key:"on",value:function(t,e){return this.handlers[t].push(e),this}},{key:"once",value:function(t,e){return this.singles[t].unshift(e),this}},{key:"emit",value:function(t,e){for(;this.singles[t].length;)this.singles[t].pop()(e);for(var n=this.handlers[t].length;--n>-1;)this.handlers[t][n](e);return this}}]),t}();e["default"]=function(t,e){return new u(t,e)}},function(t,e){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(e,function(){return this}())},function(t,e,n){var r=n(5),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){function r(t,e,n){function r(e){var n=m,r=x;return m=x=void 0,E=e,w=t.apply(r,n)}function a(t){return E=t,j=setTimeout(h,e),_?r(t):w}function l(t){var n=t-O,r=t-E,i=e-n;return M?s(i,g-r):i}function d(t){var n=t-O,r=t-E;return void 0===O||n>=e||n<0||M&&r>=g}function h(){var t=o();return d(t)?p(t):void(j=setTimeout(h,l(t)))}function p(t){return j=void 0,T&&m?r(t):(m=x=void 0,w)}function v(){void 0!==j&&clearTimeout(j),E=0,m=O=x=j=void 0}function y(){return void 0===j?w:p(o())}function b(){var t=o(),n=d(t);if(m=arguments,x=this,O=t,n){if(void 0===j)return a(O);if(M)return j=setTimeout(h,e),r(O)}return void 0===j&&(j=setTimeout(h,e)),w}var m,x,g,w,j,O,E=0,_=!1,M=!1,T=!0;if("function"!=typeof t)throw new TypeError(f);return e=u(e)||0,i(n)&&(_=!!n.leading,M="maxWait"in n,g=M?c(u(n.maxWait)||0,e):g,T="trailing"in n?!!n.trailing:T),b.cancel=v,b.flush=y,b}var i=n(2),o=n(8),u=n(10),f="Expected a function",c=Math.max,s=Math.min;t.exports=r},function(t,e,n){var r=n(6),i=function(){return r.Date.now()};t.exports=i},function(t,e,n){function r(t,e,n){var r=!0,f=!0;if("function"!=typeof t)throw new TypeError(u);return o(n)&&(r="leading"in n?!!n.leading:r,f="trailing"in n?!!n.trailing:f),i(t,e,{leading:r,maxWait:e,trailing:f})}var i=n(7),o=n(2),u="Expected a function";t.exports=r},function(t,e){function n(t){return t}t.exports=n}])});

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

!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}for(var i=n(4),o=r(i),u=200,f=document.querySelector(".field"),c=function(){var t=document.createElement("div");return t.className="dot",t.style.top=100*Math.random()+"%",t.style.left=100*Math.random()+"%",t};u--;)f.appendChild(c());o["default"].offset(50),(0,o["default"])(".dot").on("enter",function(t){return t.classList.add("in-view")}).on("exit",function(t){return t.classList.remove("in-view")})},function(t,e){function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e){"use strict";function n(t,e){var n=t.getBoundingClientRect(),r=n.top,i=n.right,o=n.bottom,u=n.left,f={t:o,r:window.innerWidth-u,b:window.innerHeight-r,l:i};return f.t>e.top&&f.r>e.right&&f.b>e.bottom&&f.l>e.left}Object.defineProperty(e,"__esModule",{value:!0}),e.inViewport=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(12),o=r(i),u=n(5),f=r(u),c=n(2),a=function(){var t=100,e=["scroll","resize","load"],n={history:[]},r={},i=(0,o["default"])(function(){n.history.forEach(function(t){n[t].check(r)})},t);e.forEach(function(t){return addEventListener(t,i)}),window.MutationObserver&&new MutationObserver(i).observe(document.body,{attributes:!0,childList:!0,subtree:!0});var u=function(t){if("string"==typeof t){var e=[].slice.call(document.querySelectorAll(t));return n.history.indexOf(t)>-1?n[t].elements=e:(n[t]=(0,f["default"])(e),n.history.push(t)),n[t]}};return u.offset=function(t){var e=function(t){return"number"==typeof t};return["top","right","bottom","left"].forEach(e(t)?function(e){return r[e]=t}:function(n){return e(t[n])?r[n]=t[n]:null}),r},u.is=c.inViewport,u.offset(0),u};e["default"]=a()},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(3),o=r(i);t.exports=o["default"]},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=n(2),u=function(){function t(e){r(this,t),this.current=[],this.elements=e,this.handlers={enter:[],exit:[]},this.singles={enter:[],exit:[]}}return i(t,[{key:"check",value:function(t){var e=this;return this.elements.forEach(function(n){var r=(0,o.inViewport)(n,t),i=e.current.indexOf(n),u=i>-1,f=r&&!u,c=!r&&u;f&&(e.current.push(n),e.emit("enter",n)),c&&(e.current.splice(i,1),e.emit("exit",n))}),this}},{key:"on",value:function(t,e){return this.handlers[t].push(e),this}},{key:"once",value:function(t,e){return this.singles[t].unshift(e),this}},{key:"emit",value:function(t,e){for(;this.singles[t].length;)this.singles[t].pop()(e);for(var n=this.handlers[t].length;--n>-1;)this.handlers[t][n](e);return this}}]),t}();e["default"]=function(t){return new u(t)}},function(t,e){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(e,function(){return this}())},function(t,e,n){var r=n(6),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){function r(t,e,n){function r(e){var n=b,r=x;return b=x=void 0,M=e,w=t.apply(r,n)}function s(t){return M=t,O=setTimeout(v,e),_?r(t):w}function l(t){var n=t-j,r=t-M,i=e-n;return E?a(i,g-r):i}function d(t){var n=t-j,r=t-M;return void 0===j||n>=e||n<0||E&&r>=g}function v(){var t=o();return d(t)?p(t):void(O=setTimeout(v,l(t)))}function p(t){return O=void 0,T&&b?r(t):(b=x=void 0,w)}function h(){void 0!==O&&clearTimeout(O),M=0,b=j=x=O=void 0}function y(){return void 0===O?w:p(o())}function m(){var t=o(),n=d(t);if(b=arguments,x=this,j=t,n){if(void 0===O)return s(j);if(E)return O=setTimeout(v,e),r(j)}return void 0===O&&(O=setTimeout(v,e)),w}var b,x,g,w,O,j,M=0,_=!1,E=!1,T=!0;if("function"!=typeof t)throw new TypeError(f);return e=u(e)||0,i(n)&&(_=!!n.leading,E="maxWait"in n,g=E?c(u(n.maxWait)||0,e):g,T="trailing"in n?!!n.trailing:T),m.cancel=h,m.flush=y,m}var i=n(1),o=n(11),u=n(13),f="Expected a function",c=Math.max,a=Math.min;t.exports=r},function(t,e){function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,e,n){function r(t){return"symbol"==typeof t||i(t)&&f.call(t)==o}var i=n(9),o="[object Symbol]",u=Object.prototype,f=u.toString;t.exports=r},function(t,e,n){var r=n(7),i=function(){return r.Date.now()};t.exports=i},function(t,e,n){function r(t,e,n){var r=!0,f=!0;if("function"!=typeof t)throw new TypeError(u);return o(n)&&(r="leading"in n?!!n.leading:r,f="trailing"in n?!!n.trailing:f),i(t,e,{leading:r,maxWait:e,trailing:f})}var i=n(8),o=n(1),u="Expected a function";t.exports=r},function(t,e,n){function r(t){if("number"==typeof t)return t;if(o(t))return u;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(f,"");var n=a.test(t);return n||s.test(t)?l(t.slice(2),n?2:8):c.test(t)?u:+t}var i=n(1),o=n(10),u=NaN,f=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;t.exports=r}]);
!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}for(var i=n(4),o=r(i),u=200,f=document.querySelector(".field"),c=function(){var t=document.createElement("div");return t.className="dot",t.style.top=100*Math.random()+"%",t.style.left=100*Math.random()+"%",t};u--;)f.appendChild(c());o["default"].offset(50),(0,o["default"])(".dot").on("enter",function(t){return t.classList.add("in-view")}).on("exit",function(t){return t.classList.remove("in-view")})},function(t,e){function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e){"use strict";function n(t,e){var n=t.getBoundingClientRect(),r=n.top,i=n.right,o=n.bottom,u=n.left,f={t:o,r:window.innerWidth-u,b:window.innerHeight-r,l:i};return f.t>e.top&&f.r>e.right&&f.b>e.bottom&&f.l>e.left}Object.defineProperty(e,"__esModule",{value:!0}),e.inViewport=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(12),o=r(i),u=n(5),f=r(u),c=n(2),s=function(){var t=100,e=["scroll","resize","load"],n={history:[]},r={},i=(0,o["default"])(function(){n.history.forEach(function(t){n[t].check()})},t);e.forEach(function(t){return addEventListener(t,i)}),window.MutationObserver&&new MutationObserver(i).observe(document.body,{attributes:!0,childList:!0,subtree:!0});var u=function(t){if("string"==typeof t){var e=[].slice.call(document.querySelectorAll(t));return n.history.indexOf(t)>-1?n[t].elements=e:(n[t]=(0,f["default"])(e,r),n.history.push(t)),n[t]}};return u.offset=function(t){var e=function(t){return"number"==typeof t};return["top","right","bottom","left"].forEach(e(t)?function(e){return r[e]=t}:function(n){return e(t[n])?r[n]=t[n]:null}),r},u.is=function(t){return(0,c.inViewport)(t,r)},u.offset(0),u};e["default"]=s()},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(3),o=r(i);t.exports=o["default"]},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=n(2),u=function(){function t(e,n){r(this,t),this.offset=n,this.current=[],this.elements=e,this.handlers={enter:[],exit:[]},this.singles={enter:[],exit:[]}}return i(t,[{key:"check",value:function(){var t=this;return this.elements.forEach(function(e){var n=(0,o.inViewport)(e,t.offset),r=t.current.indexOf(e),i=r>-1,u=n&&!i,f=!n&&i;u&&(t.current.push(e),t.emit("enter",e)),f&&(t.current.splice(r,1),t.emit("exit",e))}),this}},{key:"on",value:function(t,e){return this.handlers[t].push(e),this}},{key:"once",value:function(t,e){return this.singles[t].unshift(e),this}},{key:"emit",value:function(t,e){for(;this.singles[t].length;)this.singles[t].pop()(e);for(var n=this.handlers[t].length;--n>-1;)this.handlers[t][n](e);return this}}]),t}();e["default"]=function(t,e){return new u(t,e)}},function(t,e){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(e,function(){return this}())},function(t,e,n){var r=n(6),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){function r(t,e,n){function r(e){var n=b,r=x;return b=x=void 0,M=e,w=t.apply(r,n)}function a(t){return M=t,O=setTimeout(v,e),_?r(t):w}function l(t){var n=t-j,r=t-M,i=e-n;return E?s(i,g-r):i}function d(t){var n=t-j,r=t-M;return void 0===j||n>=e||n<0||E&&r>=g}function v(){var t=o();return d(t)?p(t):void(O=setTimeout(v,l(t)))}function p(t){return O=void 0,T&&b?r(t):(b=x=void 0,w)}function h(){void 0!==O&&clearTimeout(O),M=0,b=j=x=O=void 0}function y(){return void 0===O?w:p(o())}function m(){var t=o(),n=d(t);if(b=arguments,x=this,j=t,n){if(void 0===O)return a(j);if(E)return O=setTimeout(v,e),r(j)}return void 0===O&&(O=setTimeout(v,e)),w}var b,x,g,w,O,j,M=0,_=!1,E=!1,T=!0;if("function"!=typeof t)throw new TypeError(f);return e=u(e)||0,i(n)&&(_=!!n.leading,E="maxWait"in n,g=E?c(u(n.maxWait)||0,e):g,T="trailing"in n?!!n.trailing:T),m.cancel=h,m.flush=y,m}var i=n(1),o=n(11),u=n(13),f="Expected a function",c=Math.max,s=Math.min;t.exports=r},function(t,e){function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,e,n){function r(t){return"symbol"==typeof t||i(t)&&f.call(t)==o}var i=n(9),o="[object Symbol]",u=Object.prototype,f=u.toString;t.exports=r},function(t,e,n){var r=n(7),i=function(){return r.Date.now()};t.exports=i},function(t,e,n){function r(t,e,n){var r=!0,f=!0;if("function"!=typeof t)throw new TypeError(u);return o(n)&&(r="leading"in n?!!n.leading:r,f="trailing"in n?!!n.trailing:f),i(t,e,{leading:r,maxWait:e,trailing:f})}var i=n(8),o=n(1),u="Expected a function";t.exports=r},function(t,e,n){function r(t){if("number"==typeof t)return t;if(o(t))return u;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(f,"");var n=s.test(t);return n||a.test(t)?l(t.slice(2),n?2:8):c.test(t)?u:+t}var i=n(1),o=n(10),u=NaN,f=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt;t.exports=r}]);
{
"name": "in-view",
"version": "0.4.0",
"version": "0.4.1",
"description": "Get notified when a DOM element enters or exits the viewport.",

@@ -5,0 +5,0 @@ "main": "dist/in-view.min.js",

@@ -64,10 +64,12 @@ # in-view.js :eyes:

### inView.offset(\<offset>)
> By default, in-view considers something in viewport if it breaks any edge of the viewport. This can be used to set an offset from that edge. For example, an offset of `100` will consider elements in viewport if they break any edge of the viewport by at least `100` pixels. `offset` can be a positive or negative integer or an object.
> By default, in-view considers something in viewport if it breaks any edge of the viewport. This can be used to set an offset from that edge. For example, an offset of `100` will consider elements in viewport if they break any edge of the viewport by at least `100` pixels. `offset` can be a positive or negative integer.
> ```js
> // Global offset
> inView.offset(100);
> inView.offset(-50);
>
> // Per-direction offset
> ```
> Offset can also be set per-direction by passing an object.
> ```js
> inView.offset({

@@ -74,0 +76,0 @@ > top: 100,

@@ -30,3 +30,3 @@ import Registry from './registry';

selectors.history.forEach(selector => {
selectors[selector].check(offset);
selectors[selector].check();
});

@@ -69,3 +69,3 @@ }, threshold));

else {
selectors[selector] = Registry(elements);
selectors[selector] = Registry(elements, offset);
selectors.history.push(selector);

@@ -96,3 +96,3 @@ }

*/
control.is = inViewport;
control.is = el => inViewport(el, offset);
control.offset(0);

@@ -99,0 +99,0 @@ return control;

@@ -12,3 +12,4 @@ import { inViewport } from './viewport';

constructor(elements) {
constructor(elements, offset) {
this.offset = offset;
this.current = [];

@@ -24,6 +25,5 @@ this.elements = elements;

*/
check(offset) {
check() {
this.elements.forEach(el => {
let passes = inViewport(el, offset);
let passes = inViewport(el, this.offset);
let index = this.current.indexOf(el);

@@ -83,2 +83,2 @@ let current = index > -1;

export default (elements) => new inViewRegistry(elements);
export default (elements, offset) => new inViewRegistry(elements, offset);

@@ -5,4 +5,16 @@ import test from 'ava';

test('inView.is is a proxy for inViewport', t => {
t.deepEqual(inView.is, inViewport);
const stub = {
getBoundingClientRect() {
return {
top: 50,
right: 50,
bottom: 50,
left: 50
};
}
};
test('inView.is returns a boolean', t => {
t.true(typeof inView.is(stub) === 'boolean');
t.true(inView.is(stub));
});

@@ -34,7 +34,7 @@ import test from 'ava';

}
}]);
}], offset);
t.true(!registry.current.length);
registry.check(offset);
registry.check();
t.true(registry.current.length === 1);

@@ -57,6 +57,6 @@

let registry = Registry([stub]);
let registry = Registry([stub], offset);
registry.on('enter', el => t.deepEqual(el, stub));
registry.check(offset);
registry.check();

@@ -78,6 +78,6 @@ });

let registry = Registry([stub]);
let registry = Registry([stub], offset);
registry.on('exit', el => t.deepEqual(el, stub));
registry.check(offset);
registry.check();

@@ -87,4 +87,4 @@ });

test('Registry.check returns the registry', t => {
let registry = Registry([]);
t.deepEqual(registry.check(offset), registry);
let registry = Registry([], offset);
t.deepEqual(registry.check(), registry);
});
import test from 'ava';
import Registry from '../src/registry';
const offset = {
top: 0,
right: 0,
bottom: 0,
left: 0
};
test('Registry returns a registry', t => {
let registry = Registry([document.body]);
let registry = Registry([document.body], offset);
t.deepEqual(registry, {
offset: offset,
current: [],

@@ -8,0 +16,0 @@ elements: [document.body],

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc