New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-in-viewport

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-in-viewport - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

14

dist/es/lib/handleViewport.js

@@ -14,8 +14,2 @@ "use strict";

function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
var isFunctionalComponent = Component => {
return typeof Component === 'function' && !(Component.prototype && Component.prototype.render);
};
var isReactComponent = Component => {
return Component.prototype && Component.prototype.isReactComponent;
};
function handleViewport(TargetComponent, options, config) {

@@ -29,7 +23,7 @@ if (options === void 0) {

var ForwardedRefComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
var refProps = _extends({
var refProps = {
forwardedRef: ref
}, isReactComponent(TargetComponent) && !isFunctionalComponent(TargetComponent) ? {
ref
} : {});
// pass both ref/forwardedRef for class component for backward compatibility
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _extends({}, props, refProps));

@@ -36,0 +30,0 @@ });

@@ -32,3 +32,2 @@ "use strict";

var targetRef = target.current;
console.log(target);
if (targetRef) {

@@ -35,0 +34,0 @@ var node = targetRef;

@@ -14,8 +14,2 @@ "use strict";

function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
var isFunctionalComponent = function isFunctionalComponent(Component) {
return typeof Component === 'function' && !(Component.prototype && Component.prototype.render);
};
var isReactComponent = function isReactComponent(Component) {
return Component.prototype && Component.prototype.isReactComponent;
};
function handleViewport(TargetComponent, options, config) {

@@ -29,7 +23,7 @@ if (options === void 0) {

var ForwardedRefComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
var refProps = _extends({
var refProps = {
forwardedRef: ref
}, isReactComponent(TargetComponent) && !isFunctionalComponent(TargetComponent) ? {
ref: ref
} : {});
// pass both ref/forwardedRef for class component for backward compatibility
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _extends({}, props, refProps));

@@ -36,0 +30,0 @@ });

@@ -30,3 +30,2 @@ "use strict";

var targetRef = target.current;
console.log(target);
if (targetRef) {

@@ -33,0 +32,0 @@ var node = targetRef;

@@ -9,8 +9,2 @@ var _excluded = ["onEnterViewport", "onLeaveViewport"];

import { jsx as _jsx } from "react/jsx-runtime";
var isFunctionalComponent = function isFunctionalComponent(Component) {
return typeof Component === 'function' && !(Component.prototype && Component.prototype.render);
};
var isReactComponent = function isReactComponent(Component) {
return Component.prototype && Component.prototype.isReactComponent;
};
function handleViewport(TargetComponent, options, config) {

@@ -24,7 +18,7 @@ if (options === void 0) {

var ForwardedRefComponent = /*#__PURE__*/forwardRef(function (props, ref) {
var refProps = _extends({
var refProps = {
forwardedRef: ref
}, isReactComponent(TargetComponent) && !isFunctionalComponent(TargetComponent) ? {
ref: ref
} : {});
// pass both ref/forwardedRef for class component for backward compatibility
};
return /*#__PURE__*/_jsx(TargetComponent, _extends({}, props, refProps));

@@ -31,0 +25,0 @@ });

@@ -26,3 +26,2 @@ import { useEffect, useRef, useState } from 'react';

var targetRef = target.current;
console.log(target);
if (targetRef) {

@@ -29,0 +28,0 @@ var node = targetRef;

@@ -46,2 +46,3 @@ "use strict";

},
ref: this.props.forwardedRef,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _extends({}, props))

@@ -48,0 +49,0 @@ });

@@ -5,3 +5,3 @@ "use strict";

exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _react = require("react");
var _reactAspectRatio = require("react-aspect-ratio");

@@ -11,4 +11,2 @@ var _constants = require("./constants");

var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }

@@ -75,2 +73,3 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

},
ref: this.props.forwardedRef,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {

@@ -77,0 +76,0 @@ src: this.state.src,

@@ -11,9 +11,2 @@ "use strict";

const constants_1 = require("./constants");
const isFunctionalComponent = (Component) => {
return (typeof Component === 'function'
&& !(Component.prototype && Component.prototype.render));
};
const isReactComponent = (Component) => {
return Component.prototype && Component.prototype.isReactComponent;
};
function handleViewport(TargetComponent, options = constants_1.defaultOptions, config = constants_1.defaultConfig) {

@@ -24,6 +17,2 @@ const ForwardedRefComponent = (0, react_1.forwardRef)((props, ref) => {

// pass both ref/forwardedRef for class component for backward compatibility
...(isReactComponent(TargetComponent)
&& !isFunctionalComponent(TargetComponent)
? { ref }
: {}),
};

@@ -44,3 +33,3 @@ return (0, jsx_runtime_1.jsx)(TargetComponent, { ...props, ...refProps });

};
return ((0, jsx_runtime_1.jsx)(ForwardedRefComponent, { ...props, ref: node }));
return (0, jsx_runtime_1.jsx)(ForwardedRefComponent, { ...props, ref: node });
};

@@ -47,0 +36,0 @@ const name = TargetComponent.displayName

@@ -15,3 +15,2 @@ "use strict";

const targetRef = target.current;
console.log(target);
if (targetRef) {

@@ -18,0 +17,0 @@ const node = targetRef;

@@ -24,8 +24,2 @@ (function (global, factory) {

function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
var isFunctionalComponent = function isFunctionalComponent(Component) {
return typeof Component === 'function' && !(Component.prototype && Component.prototype.render);
};
var isReactComponent = function isReactComponent(Component) {
return Component.prototype && Component.prototype.isReactComponent;
};
function handleViewport(TargetComponent, options, config) {

@@ -39,7 +33,7 @@ if (options === void 0) {

var ForwardedRefComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
var refProps = _extends({
var refProps = {
forwardedRef: ref
}, isReactComponent(TargetComponent) && !isFunctionalComponent(TargetComponent) ? {
ref: ref
} : {});
// pass both ref/forwardedRef for class component for backward compatibility
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TargetComponent, _extends({}, props, refProps));

@@ -46,0 +40,0 @@ });

@@ -41,3 +41,2 @@ (function (global, factory) {

var targetRef = target.current;
console.log(target);
if (targetRef) {

@@ -44,0 +43,0 @@ var node = targetRef;

{
"name": "react-in-viewport",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Track React component in viewport using Intersection Observer API",

@@ -5,0 +5,0 @@ "author": "Roderick Hsiao <roderickhsiao@gmail.com>",

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