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

react-native-fit-image

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-fit-image - npm Package Compare versions

Comparing version 1.4.8 to 1.4.9

114

dist/FitImage.js

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

Object.defineProperty(exports,"__esModule",{value:true});var _jsxFileName='src/FitImage.js';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 _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 _react=require('react');var _react2=_interopRequireDefault(_react);
Object.defineProperty(exports,"__esModule",{value:true});var _jsxFileName='src/FitImage.js';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 _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 _react=require('react');var _react2=_interopRequireDefault(_react);
var _reactNative=require('react-native');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 _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;}

@@ -23,3 +23,3 @@

alignItems:'center',
justifyContent:'center'}});var
justifyContent:'center'}});var

@@ -29,3 +29,3 @@

FitImage=function(_Image){_inherits(FitImage,_Image);
function FitImage(props){_classCallCheck(this,FitImage);var _this=_possibleConstructorReturn(this,Object.getPrototypeOf(FitImage).call(this,
function FitImage(props){_classCallCheck(this,FitImage);var _this=_possibleConstructorReturn(this,(FitImage.__proto__||Object.getPrototypeOf(FitImage)).call(this,
props));

@@ -40,12 +40,12 @@

throw new Error('Props error: size props must be present '+
'none or both of width and height.');}}
'none or both of width and height.');
}
}
var originalSize=[props.originalWidth,props.originalHeight];
if(originalSize.filter(function(e){return e;}).length===1){
throw new Error('Props error: originalSize props must be present '+
'none or both of originalWidth and originalHeight.');}
'none or both of originalWidth and originalHeight.');
}
_this.isFirstLoad=true;

@@ -70,6 +70,6 @@

_this.resize=_this.resize.bind(_this);
_this.setStateSize=_this.setStateSize.bind(_this);return _this;}_createClass(FitImage,[{key:'componentDidMount',value:function componentDidMount()
_this.setStateSize=_this.setStateSize.bind(_this);return _this;
}_createClass(FitImage,[{key:'componentDidMount',value:function componentDidMount()
{var _this2=this;
{
if(this.props.originalWidth&&this.props.originalHeight)return;

@@ -79,61 +79,55 @@ if(!this.props.source.uri)return;

this.mounted=true;
this.refreshStateSize();
}},{key:'componentWillUnmount',value:function componentWillUnmount()
_reactNative.Image.getSize(this.props.source.uri,function(originalWidth,originalHeight){
if(!_this2.mounted){
return;}
_this2.setStateSize(originalWidth,originalHeight);});}},{key:'componentWillUnmount',value:function componentWillUnmount()
{
this.mounted=false;}},{key:'onLoad',value:function onLoad()
this.mounted=false;
}},{key:'onLoad',value:function onLoad()
{
this.setState({isLoading:false});
this.refreshStateSize();
if(typeof this.props.onLoad==='function'){
this.props.onLoad();}}},{key:'onLoadStart',value:function onLoadStart()
this.props.onLoad();
}
}},{key:'onLoadStart',value:function onLoadStart()
{
if(this.isFirstLoad){
this.setState({isLoading:true});
this.isFirstLoad=false;}}},{key:'getHeight',value:function getHeight(
this.isFirstLoad=false;
}
}},{key:'getHeight',value:function getHeight(
layoutWidth){
if(this.style&&this.style.height){
return this.style.height;}
return this.style.height;
}
return this.getOriginalHeight()*this.getRatio(layoutWidth);
}},{key:'getOriginalHeight',value:function getOriginalHeight()
return this.getOriginalHeight()*this.getRatio(layoutWidth);}},{key:'getOriginalHeight',value:function getOriginalHeight()
{
return this.props.originalHeight||this.state.originalHeight;}},{key:'getOriginalWidth',value:function getOriginalWidth()
return this.props.originalHeight||this.state.originalHeight;
}},{key:'getOriginalWidth',value:function getOriginalWidth()
{
return this.props.originalWidth||this.state.originalWidth;}},{key:'getRatio',value:function getRatio(
return this.props.originalWidth||this.state.originalWidth;
}},{key:'getRatio',value:function getRatio(
width){
var layoutWidth=width||this.state.layoutWidth;
return layoutWidth/this.getOriginalWidth();}},{key:'getStyle',value:function getStyle()
return layoutWidth/this.getOriginalWidth();
}},{key:'getStyle',value:function getStyle()
{
if(this.style&&this.style.width){
return {width:this.style.width};}
return{width:this.style.width};
}
return{flexGrow:1};
}},{key:'resize',value:function resize(
return {flexGrow:1};}},{key:'resize',value:function resize(
event){var
event){var
width=event.nativeEvent.layout.width;

@@ -144,6 +138,16 @@ var height=this.getHeight(width);

height:height,
layoutWidth:width});}},{key:'setStateSize',value:function setStateSize(
layoutWidth:width});
}},{key:'refreshStateSize',value:function refreshStateSize()
{var _this2=this;
_reactNative.Image.getSize(this.props.source.uri,function(originalWidth,originalHeight){
if(!_this2.mounted){
return;
}
_this2.setStateSize(originalWidth,originalHeight);
});
}},{key:'setStateSize',value:function setStateSize(
originalWidth,originalHeight){

@@ -155,21 +159,21 @@ var height=this.state.layoutWidth/originalWidth;

originalHeight:originalHeight,
originalWidth:originalWidth});}},{key:'renderChildren',value:function renderChildren()
originalWidth:originalWidth});
}},{key:'renderChildren',value:function renderChildren()
{
if(this.state.isLoading&&this.props.indicator!==false){
return (
return(
_react2.default.createElement(_reactNative.ActivityIndicator,{
color:this.props.indicatorColor,
size:this.props.indicatorSize,__source:{fileName:_jsxFileName,lineNumber:156}}));}
size:this.props.indicatorSize,__source:{fileName:_jsxFileName,lineNumber:160}}));
}
return this.props.children;
}},{key:'render',value:function render()
return this.props.children;}},{key:'render',value:function render()
{
return (
return(
_react2.default.createElement(_reactNative.Image,_extends({},

@@ -185,13 +189,13 @@ this.props,{

{height:this.state.height},
styles.container],__source:{fileName:_jsxFileName,lineNumber:168}}),
styles.container],__source:{fileName:_jsxFileName,lineNumber:172}}),
this.renderChildren()));}}]);return FitImage;}(_reactNative.Image);
this.renderChildren()));
}}]);return FitImage;}(_reactNative.Image);
FitImage.propTypes=propTypes;exports.default=
FitImage;
{
"name": "react-native-fit-image",
"version": "1.4.8",
"version": "1.4.9",
"description": "Responsive image component to fit perfectly itself.",

@@ -5,0 +5,0 @@ "main": "dist/FitImage.js",

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