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

react-within-viewport

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-within-viewport - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

.travis.yml

2

dist/bundle.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.WithinViewport=t(require("react")):e.WithinViewport=t(e.react)}(this,function(e){return function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return e[i].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=i(o);t.default=r.default},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(){}Object.defineProperty(t,"__esModule",{value:!0});var f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(7),d=i(l),s=n(6),p=i(s),v=n(5),w=i(v),h=n(3),g=i(h),y=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().height:e?e.clientHeight:null},m=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().width:e?e.clientWidth:null},b=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().top:e?e.clientTop:null},O=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().left:e?e.clientLeft:null},j=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e||t?e.innerHeight||t.clientHeight:null},_=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e||t?e.innerWidth||t.clientWidth:null},V=function(e){var t=e.inViewport;return{inViewport:t}},T={width:"100%",height:"100%",padding:0,border:0},x=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.transform,n=void 0===t?V:t,i=e.containerStyle,s=void 0===i?T:i,v=e.getHeight,h=void 0===v?y:v,x=e.getWidth,R=void 0===x?m:x,W=e.getTop,L=void 0===W?b:W,C=e.getLeft,E=void 0===C?O:C,H=e.getViewportHeight,M=void 0===H?j:H,S=e.getViewportWidth,U=void 0===S?_:S,k=e.defaultAnswer,z=void 0===k?!0:k,B=e.wait,P=void 0===B?200:B,q=e.onViewportEnter,A=void 0===q?a:q,F=e.onViewportLeave,N=void 0===F?a:F;return function(e){var t,i;return i=t=function(t){function i(){var e,t,n,u;o(this,i);for(var a=arguments.length,c=Array(a),l=0;a>l;l++)c[l]=arguments[l];return t=n=r(this,(e=Object.getPrototypeOf(i)).call.apply(e,[this].concat(c))),n.state={containerWidth:null,containerHeight:null,containerTopOffset:null,containerLeftOffset:null,windowWidth:null,windowHeight:null,ready:!1},n.updateResize=function(){if(n.mounted){var e=function(){var e=n.refs.withinViewportContainer,t={containerWidth:R(e),containerHeight:h(e),windowWidth:U(window,document),windowHeight:M(window,document)};n.setState(f({},t,{ready:n.isReady(f({},n.state,t))}))};"undefined"!=typeof window&&null!==window&&window.requestAnimationFrame?window.requestAnimationFrame(function(){return e()}):e()}},n.updateScroll=function(){if(n.mounted){var e=function(){var e=n.refs.withinViewportContainer,t={containerTopOffset:L(e),containerLeftOffset:E(e)};n.setState(f({},t,{ready:n.isReady(f({},n.state,t))}))};"undefined"!=typeof window&&null!==window&&window.requestAnimationFrame?window.requestAnimationFrame(function(){return e()}):e()}},n.isReady=function(){var e=arguments.length<=0||void 0===arguments[0]?n.state:arguments[0];return null!==e.containerWidth&&null!==e.containerHeight&&null!==e.containerTopOffset&&null!==e.containerLeftOffset&&null!==e.windowHeight&&null!==e.windowWidth},n.inViewport=function(){var e=arguments.length<=0||void 0===arguments[0]?n.state:arguments[0];return e.ready?(e.containerTopOffset<0&&e.containerHeight+e.containerTopOffset>0||e.containerTopOffset>=0&&e.containerTopOffset<e.windowHeight)&&(e.containerLeftOffset<0&&e.containerWidth+e.containerLeftOffset>0||e.containerLeftOffset>=0&&e.containerLeftOffset<e.windowWidth):z},u=t,r(n,u)}return u(i,t),c(i,[{key:"componentDidMount",value:function(){"undefined"!=typeof window&&null!==window&&window.addEventListener&&(this.mounted=!0,this.debouncedUpdateResize=(0,g.default)(this.updateResize,P),this.debouncedUpdateScroll=(0,g.default)(this.updateScroll,P),window.addEventListener("resize",this.debouncedUpdateResize,{passive:!0}),window.addEventListener("scroll",this.debouncedUpdateScroll,{passive:!0}),this.updateResize(),this.updateScroll())}},{key:"componentDidUpdate",value:function(e,t){var n=this.inViewport(t),i=this.inViewport(this.state);null===t.ready&&i===!1&&N(),null===t.ready&&i===!0&&A(),n===!0&&i===!1&&N(),n===!1&&i===!0&&A()}},{key:"componentWillUnmount",value:function(){"undefined"!=typeof window&&null!==window&&window.removeEventListener&&(this.mounted=!1,window.removeEventListener("resize",this.debouncedUpdateResize,{passive:!0}),window.removeEventListener("scroll",this.debouncedUpdateScroll,{passive:!0}))}},{key:"shouldComponentUpdate",value:function(e,t){return!(0,w.default)(this.props,e)||!(0,w.default)(n(f({inViewport:this.inViewport(this.state)},this.state)),n(f({inViewport:this.inViewport(t)},t)))}},{key:"render",value:function(){return d.default.createElement("div",{ref:"withinViewportContainer",style:s},d.default.createElement(e,f({},n(f({inViewport:this.inViewport()},this.state)),this.props)))}}]),i}(l.Component),t.displayName=(0,p.default)(e,"withinViewport"),i}};t.default=x},function(e,t){"use strict";function n(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function i(e,t){if(n(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var u=0;u<i.length;u++)if(!o.call(t,i[u])||!n(e[i[u]],t[i[u]]))return!1;return!0}var o=Object.prototype.hasOwnProperty;e.exports=i},function(e,t){function n(e,t,n){function i(t){var n=w,i=h;return w=h=void 0,V=t,y=e.apply(i,n)}function r(e){return V=e,m=setTimeout(l,t),T?i(e):y}function u(e){var n=e-_,i=e-V,o=t-n;return x?O(o,g-i):o}function c(e){var n=e-_,i=e-V;return!_||n>=t||0>n||x&&i>=g}function l(){var e=j();return c(e)?d(e):void(m=setTimeout(l,u(e)))}function d(e){return clearTimeout(m),m=void 0,R&&w?i(e):(w=h=void 0,y)}function s(){void 0!==m&&clearTimeout(m),_=V=0,w=h=m=void 0}function p(){return void 0===m?y:d(j())}function v(){var e=j(),n=c(e);if(w=arguments,h=this,_=e,n){if(void 0===m)return r(_);if(x)return clearTimeout(m),m=setTimeout(l,t),i(_)}return void 0===m&&(m=setTimeout(l,t)),y}var w,h,g,y,m,_=0,V=0,T=!1,x=!1,R=!0;if("function"!=typeof e)throw new TypeError(f);return t=a(t)||0,o(n)&&(T=!!n.leading,x="maxWait"in n,g=x?b(a(n.maxWait)||0,t):g,R="trailing"in n?!!n.trailing:R),v.cancel=s,v.flush=p,v}function i(e){var t=o(e)?m.call(e):"";return t==l||t==d}function o(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function r(e){return!!e&&"object"==typeof e}function u(e){return"symbol"==typeof e||r(e)&&m.call(e)==s}function a(e){if("number"==typeof e)return e;if(u(e))return c;if(o(e)){var t=i(e.valueOf)?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(p,"");var n=w.test(e);return n||h.test(e)?g(e.slice(2),n?2:8):v.test(e)?c:+e}var f="Expected a function",c=NaN,l="[object Function]",d="[object GeneratorFunction]",s="[object Symbol]",p=/^\s+|\s+$/g,v=/^[-+]0x[0-9a-f]+$/i,w=/^0b[01]+$/i,h=/^0o[0-7]+$/i,g=parseInt,y=Object.prototype,m=y.toString,b=Math.max,O=Math.min,j=Date.now;e.exports=n},function(e,t){"use strict";t.__esModule=!0;var n=function(e){if("string"==typeof e)return e;if(e)return e.displayName||e.name||"Component"};t.default=n},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(2),r=i(o);t.default=r.default},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(4),r=i(o),u=function(e,t){return t+"("+(0,r.default)(e)+")"};t.default=u},function(t,n){t.exports=e}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.WithinViewport=t(require("react")):e.WithinViewport=t(e.react)}(this,function(e){return function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return e[i].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),r=i(o);t.default=r.default},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(){}Object.defineProperty(t,"__esModule",{value:!0});var f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(7),d=i(l),s=n(6),p=i(s),v=n(5),w=i(v),h=n(3),g=i(h),y=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().height:e?e.clientHeight:null},m=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().width:e?e.clientWidth:null},b=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().top:e?e.clientTop:null},O=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return e&&e.getBoundingClientRect?e.getBoundingClientRect().left:e?e.clientLeft:null},j=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e||t?e.innerHeight||t.clientHeight:null},_=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e||t?e.innerWidth||t.clientWidth:null},V=function(e){var t=e.inViewport;return{inViewport:t}},T={width:"100%",height:"100%",padding:0,border:0},x=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.transform,n=void 0===t?V:t,i=e.containerStyle,s=void 0===i?T:i,v=e.getHeight,h=void 0===v?y:v,x=e.getWidth,R=void 0===x?m:x,W=e.getTop,L=void 0===W?b:W,C=e.getLeft,E=void 0===C?O:C,H=e.getViewportHeight,U=void 0===H?j:H,M=e.getViewportWidth,S=void 0===M?_:M,k=e.defaultAnswer,z=void 0===k?!0:k,B=e.wait,P=void 0===B?200:B,q=e.onViewportEnter,A=void 0===q?a:q,F=e.onViewportLeave,N=void 0===F?a:F;return function(e){var t,i;return i=t=function(t){function i(){var e,t,n,u;o(this,i);for(var a=arguments.length,c=Array(a),l=0;a>l;l++)c[l]=arguments[l];return t=n=r(this,(e=Object.getPrototypeOf(i)).call.apply(e,[this].concat(c))),n.state={containerWidth:null,containerHeight:null,containerTopOffset:null,containerLeftOffset:null,windowWidth:null,windowHeight:null,ready:!1},n.updateResize=function(){var e=function(){if(n.canUpdate){var e=n.refs.withinViewportContainer,t={containerWidth:R(e),containerHeight:h(e),windowWidth:S(window,document),windowHeight:U(window,document)};n.setState(f({},t,{ready:n.isReady(f({},n.state,t))}))}};"undefined"!=typeof window&&null!==window&&window.requestAnimationFrame?window.requestAnimationFrame(function(){return e()}):e()},n.updateScroll=function(){var e=function(){if(n.canUpdate){var e=n.refs.withinViewportContainer,t={containerTopOffset:L(e),containerLeftOffset:E(e)};n.setState(f({},t,{ready:n.isReady(f({},n.state,t))}))}};"undefined"!=typeof window&&null!==window&&window.requestAnimationFrame?window.requestAnimationFrame(function(){return e()}):e()},n.isReady=function(){var e=arguments.length<=0||void 0===arguments[0]?n.state:arguments[0];return null!==e.containerWidth&&null!==e.containerHeight&&null!==e.containerTopOffset&&null!==e.containerLeftOffset&&null!==e.windowHeight&&null!==e.windowWidth},n.inViewport=function(){var e=arguments.length<=0||void 0===arguments[0]?n.state:arguments[0];return e.ready?(e.containerTopOffset<0&&e.containerHeight+e.containerTopOffset>0||e.containerTopOffset>=0&&e.containerTopOffset<e.windowHeight)&&(e.containerLeftOffset<0&&e.containerWidth+e.containerLeftOffset>0||e.containerLeftOffset>=0&&e.containerLeftOffset<e.windowWidth):z},u=t,r(n,u)}return u(i,t),c(i,[{key:"componentDidMount",value:function(){"undefined"!=typeof window&&null!==window&&window.addEventListener&&(this.canUpdate=!0,this.debouncedUpdateResize=(0,g.default)(this.updateResize,P),this.debouncedUpdateScroll=(0,g.default)(this.updateScroll,P),window.addEventListener("resize",this.debouncedUpdateResize,{passive:!0}),window.addEventListener("scroll",this.debouncedUpdateScroll,{passive:!0}),this.updateResize(),this.updateScroll())}},{key:"componentDidUpdate",value:function(e,t){var n=this.inViewport(t),i=this.inViewport(this.state);null===t.ready&&i===!1&&N(),null===t.ready&&i===!0&&A(),n===!0&&i===!1&&N(),n===!1&&i===!0&&A()}},{key:"componentWillUnmount",value:function(){"undefined"!=typeof window&&null!==window&&window.removeEventListener&&(this.canUpdate=!1,window.removeEventListener("resize",this.debouncedUpdateResize,{passive:!0}),window.removeEventListener("scroll",this.debouncedUpdateScroll,{passive:!0}))}},{key:"shouldComponentUpdate",value:function(e,t){return!(0,w.default)(this.props,e)||!(0,w.default)(n(f({inViewport:this.inViewport(this.state)},this.state)),n(f({inViewport:this.inViewport(t)},t)))}},{key:"render",value:function(){return d.default.createElement("div",{ref:"withinViewportContainer",style:s},d.default.createElement(e,f({},n(f({inViewport:this.inViewport()},this.state)),this.props)))}}]),i}(l.Component),t.displayName=(0,p.default)(e,"withinViewport"),i}};t.default=x},function(e,t){"use strict";function n(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function i(e,t){if(n(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var u=0;u<i.length;u++)if(!o.call(t,i[u])||!n(e[i[u]],t[i[u]]))return!1;return!0}var o=Object.prototype.hasOwnProperty;e.exports=i},function(e,t){function n(e,t,n){function i(t){var n=w,i=h;return w=h=void 0,V=t,y=e.apply(i,n)}function r(e){return V=e,m=setTimeout(l,t),T?i(e):y}function u(e){var n=e-_,i=e-V,o=t-n;return x?O(o,g-i):o}function c(e){var n=e-_,i=e-V;return!_||n>=t||0>n||x&&i>=g}function l(){var e=j();return c(e)?d(e):void(m=setTimeout(l,u(e)))}function d(e){return clearTimeout(m),m=void 0,R&&w?i(e):(w=h=void 0,y)}function s(){void 0!==m&&clearTimeout(m),_=V=0,w=h=m=void 0}function p(){return void 0===m?y:d(j())}function v(){var e=j(),n=c(e);if(w=arguments,h=this,_=e,n){if(void 0===m)return r(_);if(x)return clearTimeout(m),m=setTimeout(l,t),i(_)}return void 0===m&&(m=setTimeout(l,t)),y}var w,h,g,y,m,_=0,V=0,T=!1,x=!1,R=!0;if("function"!=typeof e)throw new TypeError(f);return t=a(t)||0,o(n)&&(T=!!n.leading,x="maxWait"in n,g=x?b(a(n.maxWait)||0,t):g,R="trailing"in n?!!n.trailing:R),v.cancel=s,v.flush=p,v}function i(e){var t=o(e)?m.call(e):"";return t==l||t==d}function o(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function r(e){return!!e&&"object"==typeof e}function u(e){return"symbol"==typeof e||r(e)&&m.call(e)==s}function a(e){if("number"==typeof e)return e;if(u(e))return c;if(o(e)){var t=i(e.valueOf)?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(p,"");var n=w.test(e);return n||h.test(e)?g(e.slice(2),n?2:8):v.test(e)?c:+e}var f="Expected a function",c=NaN,l="[object Function]",d="[object GeneratorFunction]",s="[object Symbol]",p=/^\s+|\s+$/g,v=/^[-+]0x[0-9a-f]+$/i,w=/^0b[01]+$/i,h=/^0o[0-7]+$/i,g=parseInt,y=Object.prototype,m=y.toString,b=Math.max,O=Math.min,j=Date.now;e.exports=n},function(e,t){"use strict";t.__esModule=!0;var n=function(e){if("string"==typeof e)return e;if(e)return e.displayName||e.name||"Component"};t.default=n},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(2),r=i(o);t.default=r.default},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(4),r=i(o),u=function(e,t){return t+"("+(0,r.default)(e)+")"};t.default=u},function(t,n){t.exports=e}])});

@@ -172,7 +172,7 @@ 'use strict';

}, _this.updateResize = function () {
if (!_this.mounted) {
return;
}
var update = function update() {
if (!_this.canUpdate) {
return;
}
var update = function update() {
var elem = _this.refs.withinViewportContainer;

@@ -198,7 +198,7 @@

}, _this.updateScroll = function () {
if (!_this.mounted) {
return;
}
var update = function update() {
if (!_this.canUpdate) {
return;
}
var update = function update() {
var elem = _this.refs.withinViewportContainer;

@@ -237,3 +237,3 @@

if (typeof window !== 'undefined' && window !== null && window.addEventListener) {
this.mounted = true;
this.canUpdate = true;
this.debouncedUpdateResize = (0, _lodash2.default)(this.updateResize, wait);

@@ -270,3 +270,3 @@ this.debouncedUpdateScroll = (0, _lodash2.default)(this.updateScroll, wait);

if (typeof window !== 'undefined' && window !== null && window.removeEventListener) {
this.mounted = false;
this.canUpdate = false;
window.removeEventListener('resize', this.debouncedUpdateResize, { passive: true });

@@ -273,0 +273,0 @@ window.removeEventListener('scroll', this.debouncedUpdateScroll, { passive: true });

{
"name": "react-within-viewport",
"version": "1.2.3",
"version": "1.2.4",
"description": "Debounced React high order component to flag when it's container is inside the viewport.",

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

# react-within-viewport
[![npm version](https://img.shields.io/npm/v/react-within-viewport.svg?style=flat-square)](https://www.npmjs.com/package/react-within-viewport)
[![dependency status](https://img.shields.io/david/team-magneto/react-within-viewport.svg?style=flat-square)](https://david-dm.org/team-magneto/react-within-viewport)
[![build status](https://img.shields.io/travis/team-magneto/react-within-viewport.svg?style=flat-square)](https://travis-ci.org/team-magneto/react-within-viewport)
Debounced React high order component to flag when it's container is inside the viewport.

@@ -4,0 +8,0 @@

@@ -99,3 +99,3 @@ import React, { Component } from 'react'

if (typeof window !== 'undefined' && window !== null && window.addEventListener) {
this.mounted = true
this.canUpdate = true
this.debouncedUpdateResize = debounce(this.updateResize, wait)

@@ -122,3 +122,3 @@ this.debouncedUpdateScroll = debounce(this.updateScroll, wait)

if (typeof window !== 'undefined' && window !== null && window.removeEventListener) {
this.mounted = false
this.canUpdate = false
window.removeEventListener('resize', this.debouncedUpdateResize, { passive: true })

@@ -140,5 +140,5 @@ window.removeEventListener('scroll', this.debouncedUpdateScroll, { passive: true })

updateResize = () => {
if (!this.mounted) { return }
const update = () => {
if (!this.canUpdate) { return }
const update = () => {
const elem = this.refs.withinViewportContainer

@@ -164,5 +164,5 @@

updateScroll = () => {
if (!this.mounted) { return }
const update = () => {
if (!this.canUpdate) { return }
const update = () => {
const elem = this.refs.withinViewportContainer

@@ -169,0 +169,0 @@

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