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

react-lazyload

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-lazyload - npm Package Compare versions

Comparing version

to
2.4.0

42

lib/index.js

@@ -158,3 +158,3 @@ 'use strict';

var node = _reactDom2.default.findDOMNode(component);
if (!node) {
if (!(node instanceof HTMLElement)) {
return;

@@ -208,2 +208,6 @@ }

var isString = function isString(string) {
return typeof string === 'string';
};
var LazyLoad = function (_Component) {

@@ -224,31 +228,16 @@ _inherits(LazyLoad, _Component);

value: function componentDidMount() {
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {
if (_react2.default.Children.count(this.props.children) > 1) {
console.warn('[react-lazyload] Only one child is allowed to be passed to `LazyLoad`.');
}
// It's unlikely to change delay type on the fly, this is mainly
// designed for tests
var scrollport = window;
var scrollContainer = this.props.scrollContainer;
if (this.props.wheel) {
// eslint-disable-line
console.warn('[react-lazyload] Props `wheel` is not supported anymore, try set `overflow` for lazy loading in overflow containers.');
if (scrollContainer) {
if (isString(scrollContainer)) {
scrollport = scrollport.document.querySelector(scrollContainer);
}
// Warn the user if placeholder and height is not specified and the rendered height is 0
if (!this.props.placeholder && this.props.height === undefined && _reactDom2.default.findDOMNode(this).offsetHeight === 0) {
console.warn('[react-lazyload] Please add `height` props to <LazyLoad> for better performance.');
}
}
var needResetFinalLazyLoadHandler = this.props.debounce !== undefined && delayType === 'throttle' || delayType === 'debounce' && this.props.debounce === undefined;
// It's unlikely to change delay type on the fly, this is mainly
// designed for tests
var needResetFinalLazyLoadHandler = false;
if (this.props.debounce !== undefined && delayType === 'throttle') {
console.warn('[react-lazyload] Previous delay function is `throttle`, now switching to `debounce`, try setting them unanimously');
needResetFinalLazyLoadHandler = true;
} else if (delayType === 'debounce' && this.props.debounce === undefined) {
console.warn('[react-lazyload] Previous delay function is `debounce`, now switching to `throttle`, try setting them unanimously');
needResetFinalLazyLoadHandler = true;
}
if (needResetFinalLazyLoadHandler) {
(0, _event.off)(window, 'scroll', finalLazyLoadHandler, passiveEvent);
(0, _event.off)(scrollport, 'scroll', finalLazyLoadHandler, passiveEvent);
(0, _event.off)(window, 'resize', finalLazyLoadHandler, passiveEvent);

@@ -286,3 +275,3 @@ finalLazyLoadHandler = null;

if (scroll) {
(0, _event.on)(window, 'scroll', finalLazyLoadHandler, passiveEvent);
(0, _event.on)(scrollport, 'scroll', finalLazyLoadHandler, passiveEvent);
}

@@ -350,2 +339,3 @@

placeholder: _propTypes2.default.node,
scrollContainer: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]),
unmountIfInvisible: _propTypes2.default.bool

@@ -352,0 +342,0 @@ };

@@ -12,3 +12,3 @@ 'use strict';

exports.default = function (node) {
if (!node) {
if (!(node instanceof HTMLElement)) {
return document.documentElement;

@@ -15,0 +15,0 @@ }

{
"name": "react-lazyload",
"version": "2.3.0",
"version": "2.4.0",
"description": "Lazyload your components, images or anything where performance matters.",

@@ -11,3 +11,4 @@ "main": "lib/index.js",

"build": "babel src/ --out-dir lib/",
"lint": "eslint -c .eslintrc src/"
"lint": "eslint -c .eslintrc src/",
"publish": "npm publish"
},

@@ -30,4 +31,2 @@ "repository": {

"devDependencies": {
"prop-types": "^15.5.6",
"react-transition-group": "1.x",
"babel-cli": "^6.24.0",

@@ -52,2 +51,3 @@ "babel-core": "^6.24.0",

"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^0.5.5",

@@ -60,2 +60,3 @@ "karma-coveralls": "^1.1.2",

"mocha": "^2.2.5",
"prop-types": "^15.5.6",
"react": "^16",

@@ -65,2 +66,3 @@ "react-dom": "^16",

"react-router": "^3",
"react-transition-group": "1.x",
"webpack": "~1.11.0",

@@ -67,0 +69,0 @@ "webpack-dev-server": "~1.10.1"

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

# Note
This project is now currently maintained by
@ameerthehacker, please reach out to him on any issues or help.
----
# react-lazyload [![Build Status](https://travis-ci.org/jasonslyvia/react-lazyload.svg)](https://travis-ci.org/jasonslyvia/react-lazyload) [![npm version](https://badge.fury.io/js/react-lazyload.svg)](http://badge.fury.io/js/react-lazyload) [![Coverage Status](https://coveralls.io/repos/github/jasonslyvia/react-lazyload/badge.svg?branch=master)](https://coveralls.io/github/jasonslyvia/react-lazyload?branch=master) [![npm downloads](https://img.shields.io/npm/dm/react-lazyload.svg)](https://www.npmjs.com/package/react-lazyload)

@@ -83,3 +90,3 @@

You should aware that your component will only be mounted when it's visible in viewport, before that a placeholder will be rendered.
You should be aware that your component will only be mounted when it's visible in viewport, before that a placeholder will be rendered.

@@ -90,2 +97,9 @@ So you can safely send request in your component's `componentDidMount` without worrying about performance loss or add some pretty entering effects, see this [demo](https://jasonslyvia.github.io/react-lazyload/examples/#/fadein) for more detail.

### children
Type: Node Default: undefined
**NOTICE**
Only one child is allowed to be passed.
### height

@@ -152,3 +166,3 @@

Type: Bool / Number Default: true
Type: Bool / Number Default: undefined

@@ -163,2 +177,7 @@ Lazyload will try to use [passive event](https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md) by default to improve scroll/resize event handler's performance. If you prefer control this behaviour by yourself, you can set `debounce` or `throttle` to enable built in delay feature.

### wheel
**DEPRECATED NOTICE**
This props is not supported anymore, try set `overflow` for lazy loading in overflow containers.
## Utility

@@ -182,3 +201,2 @@

## Scripts

@@ -185,0 +203,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet