nuke-image
Advanced tools
Comparing version 2.0.4 to 2.0.5
# Changelog | ||
## 2.0.5 / 2018-05-15 | ||
* [[0a9a4e3](http://gitlab.alibaba-inc.com/nuke/image/commit/0a9a4e36175c71bb89da063215ec5490e6e94ab1)] - `feat` remove nuke-env | ||
## 2.0.4 / 2018-05-15 | ||
@@ -5,0 +9,0 @@ |
@@ -13,6 +13,6 @@ /* @jsx createElement */ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _rax = require('rax'); | ||
var _nukeEnv = require('nuke-env'); | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -26,2 +26,4 @@ | ||
var isWeb = (typeof navigator === 'undefined' ? 'undefined' : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
var WIDTH_ORIGINAL = 1; | ||
@@ -43,28 +45,2 @@ var HEIGHT_ORIGINAL = 1; | ||
_this.load = function (e) { | ||
var width = void 0, | ||
height = void 0; | ||
if (_nukeEnv.isWeex) { | ||
if (e.size && e.size.naturalWidth > 0 && e.size.naturalHeight > 0) { | ||
width = _this.convertToRem(e.size.naturalWidth); | ||
height = _this.convertToRem(e.size.naturalHeight); | ||
} | ||
} else if (e.target) { | ||
width = _this.convertToRem(e.target.naturalWidth); | ||
height = _this.convertToRem(e.target.naturalHeight); | ||
e.size = { | ||
naturalWidth: width, | ||
naturalHeight: height | ||
}; | ||
} | ||
if (_this.props.autoFit && width && height) { | ||
_this.setState({ | ||
width: width, | ||
height: height | ||
}); | ||
} | ||
_this.props.onLoad && _this.props.onLoad(e); | ||
}; | ||
_this.state = { | ||
@@ -74,2 +50,3 @@ width: WIDTH_ORIGINAL, | ||
}; | ||
_this.load = _this.load.bind(_this); | ||
return _this; | ||
@@ -82,6 +59,6 @@ } | ||
var pxWidth = void 0; | ||
if (_nukeEnv.isWeex) { | ||
if (isWeb) { | ||
pxWidth = document.documentElement.clientWidth * devicePixelRatio; | ||
} else { | ||
pxWidth = WXEnvironment.deviceWidth; | ||
} else { | ||
pxWidth = document.documentElement.clientWidth * devicePixelRatio; | ||
} | ||
@@ -91,2 +68,29 @@ return Math.round(num * 750 / pxWidth); | ||
}, { | ||
key: 'load', | ||
value: function load(e) { | ||
var width = void 0; | ||
var height = void 0; | ||
if (!isWeb) { | ||
if (e.size && e.size.naturalWidth > 0 && e.size.naturalHeight > 0) { | ||
width = this.convertToRem(e.size.naturalWidth); | ||
height = this.convertToRem(e.size.naturalHeight); | ||
} | ||
} else if (e.target) { | ||
width = this.convertToRem(e.target.naturalWidth); | ||
height = this.convertToRem(e.target.naturalHeight); | ||
e.size = { | ||
naturalWidth: width, | ||
naturalHeight: height | ||
}; | ||
} | ||
if (this.props.autoFit && width && height) { | ||
this.setState({ | ||
width: width, | ||
height: height | ||
}); | ||
} | ||
this.props.onLoad && this.props.onLoad(e); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -114,6 +118,6 @@ value: function render() { | ||
var ImageElement = void 0; | ||
if (_nukeEnv.isWeex) { | ||
if (isWeb) { | ||
ImageElement = 'img'; | ||
} else { | ||
ImageElement = 'image'; | ||
} else { | ||
ImageElement = 'img'; | ||
} | ||
@@ -143,3 +147,2 @@ /** | ||
} | ||
if (_nukeEnv.isWeb) {} | ||
@@ -149,6 +152,3 @@ // for cover and contain | ||
if (propsResizeMode) { | ||
if (_nukeEnv.isWeex) { | ||
nativeProps.resize = propsResizeMode; | ||
nativeProps.style.resizeMode = propsResizeMode; | ||
} else { | ||
if (isWeb) { | ||
delete nativeProps.style.flex; | ||
@@ -158,2 +158,5 @@ nativeProps.style.width = nativeProps.style.width || '100%'; | ||
nativeProps.style.objectFit = propsResizeMode; | ||
} else { | ||
nativeProps.resize = propsResizeMode; | ||
nativeProps.style.resizeMode = propsResizeMode; | ||
} | ||
@@ -169,9 +172,2 @@ } | ||
Image.resizeMode = { | ||
contain: 'contain', | ||
cover: 'cover', | ||
stretch: 'stretch' | ||
}; | ||
Image.propTypes = { | ||
@@ -188,5 +184,6 @@ /** | ||
Image.defaultProps = { | ||
style: {} | ||
style: {}, | ||
autoFit: false | ||
}; | ||
exports.default = Image; | ||
module.exports = exports['default']; |
{ | ||
"name": "nuke-image", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "图片", | ||
@@ -13,3 +13,5 @@ "main": "lib/index", | ||
"README.md", | ||
"HISTORY.md" | ||
"HISTORY.md", | ||
"deps.json", | ||
"build" | ||
], | ||
@@ -49,5 +51,3 @@ "keywords": [ | ||
}, | ||
"dependencies": { | ||
"nuke-env": "^2.x.x" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -54,0 +54,0 @@ "nuke-page": "^2.x.x", |
Possible typosquat attack
Supply chain riskThere is a package with a similar name that is downloaded much more often.
Did you mean |
---|
use-image |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42549
0
16
387
1
- Removednuke-env@^2.x.x
- Removednuke-env@2.3.12(transitive)