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

react-super-components

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-super-components - npm Package Compare versions

Comparing version 0.3.10 to 0.4.0

37

dist/Image.js

@@ -52,2 +52,13 @@ 'use strict';

_createClass(Image, [{
key: 'componentWillMount',
value: function componentWillMount() {
var src = this.props.src;
var image = new window.Image();
image.src = src;
if (image.complete) {
this.setState({ status: 'display' });
}
}
}, {
key: 'componentDidMount',

@@ -57,4 +68,11 @@ value: function componentDidMount() {

var status = this.state.status;
if (status === 'display') {
var imageDidLoad = this.props.imageDidLoad;
if (imageDidLoad) imageDidLoad();
return;
}
this.$imageNode = (0, _jquery2.default)(_reactDom2.default.findDOMNode(this));
this.$imageNode.on('inview', function (event, isInView) {

@@ -65,10 +83,14 @@ _this2.$imageNode.off('inview');

image.onload = function (e) {
// NOTE: the timeout is meant to exagerate the loading time
window.setTimeout(function () {
_this2.setState({ status: 'display' });
}, 1000);
_this2.setState({ status: 'display' });
var imageDidLoad = _this2.props.imageDidLoad;
if (imageDidLoad) imageDidLoad();
};
image.onerror = function () {
_this2.setState({ status: 'error' });
var imageDidLoad = _this2.props.imageDidLoad;
if (imageDidLoad) imageDidLoad(Error('image failed to load'));
};
image.src = _this2.props.src;

@@ -80,3 +102,3 @@ });

value: function componentWillUnmount() {
this.$imageNode.off('inview');
if (this.$imageNode) this.$imageNode.off('inview');
}

@@ -137,5 +159,6 @@ }, {

errorComponent: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object]),
wrapperProps: _react.PropTypes.object
wrapperProps: _react.PropTypes.object,
imageDidLoad: _react.PropTypes.func
};
exports.default = Image;

2

package.json

@@ -46,3 +46,3 @@ {

},
"version": "0.3.10"
"version": "0.4.0"
}
# React Super Components
[![travis][travis-image]][travis-url]
[![npm][npm-image]][npm-url]

@@ -4,0 +5,0 @@ [![semantic-release][semantic-release-image]][semantic-release-url]

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