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

react-now-you-see-me

Package Overview
Dependencies
Maintainers
12
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-now-you-see-me - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

lib/in-view.test.js

127

lib/in-view.js

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

'use strict';
"use strict";

@@ -6,47 +6,69 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = _interopRequireDefault(require("react"));
var _react = require('react');
var _reactDom = require("react-dom");
var _react2 = _interopRequireDefault(_react);
var _lodash = _interopRequireDefault(require("lodash.debounce"));
var _reactDom = require('react-dom');
var _propTypes = require("prop-types");
var _lodash = require('lodash.debounce');
var _util = require("./util");
var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _util = require('./util');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var onWindowScroll = (0, _util.on)('scroll', { capture: true, passive: true })(window);
// eslint-disable-next-line no-undef
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var onWindowScroll = (0, _util.on)('scroll', {
capture: true,
passive: true
})(window); // eslint-disable-next-line no-undef
var isProd = process && process.env && process.env.NODE_ENV === 'production';
var InView = function (_React$Component) {
var InView =
/*#__PURE__*/
function (_React$Component) {
_inherits(InView, _React$Component);
function InView() {
var _ref;
var _getPrototypeOf2;
var _temp, _this, _ret;
var _this;
_classCallCheck(this, InView);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = InView.__proto__ || Object.getPrototypeOf(InView)).call.apply(_ref, [this].concat(args))), _this), _this.mounted = false, _this.state = {
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(InView)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "mounted", false);
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
isInView: false,
hasUpdated: false
}, _this.checkIsInView = function () {
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "checkIsInView", function () {
if (!_this.mounted) return;

@@ -56,11 +78,11 @@ if (_this.props.once && _this.state.hasUpdated) return;

if (threshold > 10 && !isProd) {
// eslint-disable-next-line no-console
console.warn('High InView threshold: "' + threshold + '". Threshold is multiplied by the viewport dimensions!');
console.warn("High InView threshold: \"".concat(threshold, "\". Threshold is multiplied by the viewport dimensions!"));
}
var wasInView = _this.state.isInView;
var isNowInView = _this.isInViewport((0, _reactDom.findDOMNode)(_this));
var isNowInView = _this.isInViewport((0, _reactDom.findDOMNode)(_assertThisInitialized(_assertThisInitialized(_this))));
if (wasInView !== isNowInView) {

@@ -74,15 +96,18 @@ _this.setState(function () {

}
}, _this.checkIsInViewDebounced = (0, _lodash2.default)(_this.checkIsInView, _this.props.debounce), _temp), _possibleConstructorReturn(_this, _ret);
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "checkIsInViewDebounced", (0, _lodash.default)(_this.checkIsInView, _this.props.debounce));
return _this;
}
_createClass(InView, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {
this.mounted = true;
var _props = this.props,
threshold = _props.threshold,
boundingLeft = _props.boundingLeft,
boundingRight = _props.boundingRight,
isFullyContained = _props.isFullyContained;
var _this$props = this.props,
threshold = _this$props.threshold,
boundingLeft = _this$props.boundingLeft,
boundingRight = _this$props.boundingRight,
isFullyContained = _this$props.isFullyContained;
this.isInViewport = (0, _util.inViewport)({

@@ -98,3 +123,3 @@ threshold: threshold,

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -105,10 +130,10 @@ this.mounted = false;

}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
var _props2 = this.props,
threshold = _props2.threshold,
debounce = _props2.debounce,
boundingLeft = _props2.boundingLeft,
boundingRight = _props2.boundingRight,
isFullyContained = _props2.isFullyContained;
var _this$props2 = this.props,
threshold = _this$props2.threshold,
debounce = _this$props2.debounce,
boundingLeft = _this$props2.boundingLeft,
boundingRight = _this$props2.boundingRight,
isFullyContained = _this$props2.isFullyContained;

@@ -123,8 +148,9 @@ if (prevProps.threshold !== threshold || prevProps.boundingLeft !== boundingLeft || prevProps.boundingRight !== boundingRight || prevProps.isFullyContained !== isFullyContained) {

}
if (prevProps.debounce !== debounce) {
this.checkIsInViewDebounced = (0, _lodash2.default)(this.checkIsInView, debounce);
this.checkIsInViewDebounced = (0, _lodash.default)(this.checkIsInView, debounce);
}
}
}, {
key: 'render',
key: "render",
value: function render() {

@@ -136,5 +162,17 @@ return this.props.children(this.state.isInView);

return InView;
}(_react2.default.Component);
}(_react.default.Component);
InView.defaultProps = {
exports.default = InView;
_defineProperty(InView, "propTypes", {
boundingLeft: _propTypes.number,
boundingRight: _propTypes.number,
children: _propTypes.func.isRequired,
debounce: _propTypes.number,
once: _propTypes.bool,
isFullyContained: _propTypes.bool,
threshold: _propTypes.number
});
_defineProperty(InView, "defaultProps", {
debounce: 250,

@@ -144,3 +182,2 @@ threshold: 0,

isFullyContained: true
};
exports.default = InView;
});

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

'use strict';
"use strict";

@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {

});
var _inView = require('./in-view');
Object.defineProperty(exports, 'default', {
Object.defineProperty(exports, "default", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_inView).default;
return _inView.default;
}
});
var _inView = _interopRequireDefault(require("./in-view"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

'use strict';
"use strict";

@@ -6,2 +6,4 @@ Object.defineProperty(exports, "__esModule", {

});
exports.inViewport = exports.isBoundingClientRectInRange = exports.on = void 0;
var isFn = function isFn(f) {

@@ -11,3 +13,3 @@ return typeof f === 'function';

var on = exports.on = function on(evtName, opts) {
var on = function on(evtName, opts) {
return function (el) {

@@ -24,2 +26,4 @@ return function (fn) {

exports.on = on;
var isBetween = function isBetween(minInclusive, max) {

@@ -31,7 +35,6 @@ return function (target) {

var isBoundingClientRectInRange = exports.isBoundingClientRectInRange = function isBoundingClientRectInRange(_ref) {
var isBoundingClientRectInRange = function isBoundingClientRectInRange(_ref) {
var targetRect = _ref.targetRect,
boundingRect = _ref.boundingRect,
fullyContained = _ref.fullyContained;
var horizBounds = isBetween(boundingRect.left, boundingRect.right);

@@ -42,14 +45,16 @@ var vertBounds = isBetween(boundingRect.top, boundingRect.bottom);

var inViewport = exports.inViewport = function inViewport() {
exports.isBoundingClientRectInRange = isBoundingClientRectInRange;
var inViewport = function inViewport() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref2$threshold = _ref2.threshold,
threshold = _ref2$threshold === undefined ? 0 : _ref2$threshold,
threshold = _ref2$threshold === void 0 ? 0 : _ref2$threshold,
_ref2$offsetVert = _ref2.offsetVert,
offsetVert = _ref2$offsetVert === undefined ? window.innerHeight * threshold : _ref2$offsetVert,
offsetVert = _ref2$offsetVert === void 0 ? window.innerHeight * threshold : _ref2$offsetVert,
_ref2$offsetHoriz = _ref2.offsetHoriz,
offsetHoriz = _ref2$offsetHoriz === undefined ? window.innerWidth * threshold : _ref2$offsetHoriz,
offsetHoriz = _ref2$offsetHoriz === void 0 ? window.innerWidth * threshold : _ref2$offsetHoriz,
boundingLeft = _ref2.boundingLeft,
boundingRight = _ref2.boundingRight,
_ref2$isFullyContaine = _ref2.isFullyContained,
isFullyContained = _ref2$isFullyContaine === undefined ? false : _ref2$isFullyContaine;
isFullyContained = _ref2$isFullyContaine === void 0 ? false : _ref2$isFullyContaine;

@@ -74,2 +79,4 @@ return function (element) {

};
};
};
exports.inViewport = inViewport;
{
"name": "react-now-you-see-me",
"description": "A React component for determining when an element is within a given threshold of the viewport, horizontally.",
"version": "1.5.0",
"version": "1.5.1",
"author": "Jane Web Team",

@@ -49,29 +49,30 @@ "contributors": [

"devDependencies": {
"babel-cli": "6.26.0",
"babel-eslint": "8.2.6",
"babel-jest": "23.4.2",
"babel-loader": "7.1.5",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-react-remove-prop-types": "0.4.14",
"babel-preset-env": "1.7.0",
"babel-preset-react": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"babel-register": "6.26.0",
"@babel/cli": "7.1.2",
"@babel/core": "7.1.2",
"@babel/plugin-proposal-class-properties": "7.1.0",
"@babel/preset-env": "7.1.0",
"@babel/preset-react": "7.0.0",
"@babel/register": "7.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"babel-loader": "8.0.4",
"babel-plugin-transform-react-remove-prop-types": "0.4.18",
"coveralls": "3.0.2",
"dom-testing-library": "2.5.0",
"eslint": "5.3.0",
"eslint-plugin-jane": "0.1.11",
"husky": "0.14.3",
"jest": "23.5.0",
"lint-staged": "7.2.2",
"marked": "0.4.0",
"eslint": "5.6.1",
"eslint-plugin-jane": "1.0.2",
"husky": "1.1.1",
"jest": "23.6.0",
"lint-staged": "7.3.0",
"marked": "0.5.1",
"npm-run-all": "4.1.3",
"prettier": "1.14.2",
"prettier": "1.14.3",
"prop-types": "15.6.2",
"react": "16.4.2",
"react-dom": "16.4.2",
"react-testing-library": "3.1.3",
"webpack": "4.16.5",
"webpack-cli": "3.1.0",
"webpack-dev-server": "3.1.5"
"react": "16.5.2",
"react-dom": "16.5.2",
"react-testing-library": "5.2.0",
"webpack": "4.20.2",
"webpack-cli": "3.1.2",
"webpack-dev-server": "3.1.9"
},

@@ -78,0 +79,0 @@ "jest": {

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