react-in-viewport
Advanced tools
Comparing version 0.0.32 to 0.0.33
@@ -20,7 +20,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var isStateless = function isStateless(Component) { | ||
return typeof Component === 'function' && !(Component.prototype && Component.prototype.isReactComponent); | ||
var isStateless = function isStateless(TargetComponent) { | ||
return typeof TargetComponent === 'function' && !(TargetComponent.prototype && TargetComponent.prototype.isReactComponent); | ||
}; | ||
function handleViewport(Component, options) { | ||
function handleViewport(TargetComponent, options) { | ||
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { disconnectOnLeave: false }; | ||
@@ -149,4 +149,4 @@ | ||
var refProps = isStateless(Component) ? { innerRef: this.setInnerRef } : { ref: this.setRef }; | ||
return React.createElement(Component, _extends({}, others, { | ||
var refProps = isStateless(TargetComponent) ? { innerRef: this.setInnerRef } : { ref: this.setRef }; | ||
return React.createElement(TargetComponent, _extends({}, others, { | ||
inViewport: this.state.inViewport, | ||
@@ -161,5 +161,5 @@ enterCount: this.state.enterCount, | ||
return hoistNonReactStatic(InViewport, Component); | ||
return hoistNonReactStatic(InViewport, TargetComponent); | ||
} | ||
export default handleViewport; |
@@ -36,7 +36,7 @@ 'use strict'; | ||
var isStateless = function isStateless(Component) { | ||
return typeof Component === 'function' && !(Component.prototype && Component.prototype.isReactComponent); | ||
var isStateless = function isStateless(TargetComponent) { | ||
return typeof TargetComponent === 'function' && !(TargetComponent.prototype && TargetComponent.prototype.isReactComponent); | ||
}; | ||
function handleViewport(Component, options) { | ||
function handleViewport(TargetComponent, options) { | ||
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { disconnectOnLeave: false }; | ||
@@ -176,4 +176,4 @@ | ||
var refProps = isStateless(Component) ? { innerRef: this.setInnerRef } : { ref: this.setRef }; | ||
return _react2.default.createElement(Component, Object.assign({}, others, { | ||
var refProps = isStateless(TargetComponent) ? { innerRef: this.setInnerRef } : { ref: this.setRef }; | ||
return _react2.default.createElement(TargetComponent, Object.assign({}, others, { | ||
inViewport: this.state.inViewport, | ||
@@ -187,5 +187,5 @@ enterCount: this.state.enterCount, | ||
return InViewport; | ||
}(Component); | ||
}(_react.Component); | ||
return (0, _hoistNonReactStatics2.default)(InViewport, Component); | ||
return (0, _hoistNonReactStatics2.default)(InViewport, TargetComponent); | ||
} | ||
@@ -192,0 +192,0 @@ |
{ | ||
"name": "react-in-viewport", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"description": "Track React component in viewport", | ||
@@ -5,0 +5,0 @@ "author": "Roderick Hsiao <roderickhsiao@gmail.com>", |
@@ -10,9 +10,9 @@ if (typeof window !== 'undefined') { | ||
const isStateless = (Component) => ( | ||
typeof Component === 'function' | ||
&& !(Component.prototype && Component.prototype.isReactComponent) | ||
const isStateless = (TargetComponent) => ( | ||
typeof TargetComponent === 'function' | ||
&& !(TargetComponent.prototype && TargetComponent.prototype.isReactComponent) | ||
) | ||
function handleViewport( | ||
Component, | ||
TargetComponent, | ||
options, | ||
@@ -131,7 +131,7 @@ config = { disconnectOnLeave: false } | ||
const refProps = isStateless(Component) | ||
const refProps = isStateless(TargetComponent) | ||
? { innerRef: this.setInnerRef } | ||
: { ref: this.setRef }; | ||
return ( | ||
<Component | ||
<TargetComponent | ||
{...others} | ||
@@ -146,5 +146,5 @@ inViewport={this.state.inViewport} | ||
} | ||
return hoistNonReactStatic(InViewport, Component); | ||
return hoistNonReactStatic(InViewport, TargetComponent); | ||
} | ||
export default handleViewport; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
338014