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

nuke-dimensions

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-dimensions - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

89

docs/basic.md
# Dimensions demo
- order: 0
* order: 0

@@ -9,6 +9,5 @@ 获取屏幕宽高信息

````js
```js
/** @jsx createElement */
import {createElement, Component,render} from 'rax';
import { createElement, Component, render } from 'rax';
import View from 'nuke-view';

@@ -19,51 +18,35 @@ import Text from 'nuke-text';

import Button from 'nuke-button';
let App = class NukeDemoIndex extends Component {
constructor() {
super();
this.state = {
width:0,
height:0
}
}
press = ()=>{
let { height, width } = Dimensions.get('window');
this.setState({
width:width,
height:height
})
}
render() {
return (
<Page title="Dimensions">
<View style={styles.result}>
{this.state.width ? <Text style={styles.resultText}>屏幕宽度:{this.state.width} rem,高度{this.state.height} rem</Text> :null}
</View>
<View style={styles.btns}>
<Button style={styles.btn} block onPress={this.press} type="primary">获取</Button>
</View>
</Page>
);
}
let { height, width, safeHeight } = Dimensions.get('window');
class App extends Component {
render() {
return (
<View
x="111"
style={{
width: 750,
height: safeHeight || height,
justifyContent: 'flex-end',
backgroundColor: '#fda085'
}}
>
<View x="222" style={styles.body}>
<Text style={styles.resultText}>
屏幕宽高:{width} * {height}
</Text>
<Text style={styles.resultText}>安全区高度:{safeHeight}</Text>
</View>
<Button type="primary">底部按钮</Button>
</View>
);
}
}
const styles={
result : {
height:'480rem',
margin:'30rem',
padding:'10rem',
backgroundColor:'#ffffff',
justifyContent:'center',
alignItems:'center'
},
resultText : {
fontSize:'28rem'
},
btns:{
margin:'30rem',
},
btn:{
marginBottom:'30rem'
}
}
render(<App/>);
````
const styles = {
body: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(255,255,255,.8)'
}
};
render(<App />);
```
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = undefined;

@@ -19,83 +18,90 @@ 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; }; }();

// const isIphoneXInWeex = isWeex ? appInfo.deviceModel === 'iPhone10,3' : false;
var isIphoneXInWeex = true;
var isQN = _nukeEnv.appInfo.appName === 'QN';
function getDimensions() {
var landscape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var landscape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var dimensions = {};
if (_nukeEnv.isWeex) {
var weexEnv = typeof WXEnvironment !== 'undefined' ? WXEnvironment : {};
weexEnv.deviceHeight = parseInt(weexEnv.deviceHeight, 10);
weexEnv.deviceWidth = parseInt(weexEnv.deviceWidth, 10);
var scale = parseFloat(weexEnv.scale, 10) || DEFAULT_SCALE;
if (landscape) {
dimensions = {
window: {
width: (weexEnv.deviceHeight * 750 / weexEnv.deviceWidth).toFixed(),
var dimensions = {};
if (_nukeEnv.isWeex) {
var weexEnv = typeof WXEnvironment !== 'undefined' ? WXEnvironment : {};
weexEnv.deviceHeight = parseInt(weexEnv.deviceHeight, 10);
weexEnv.deviceWidth = parseInt(weexEnv.deviceWidth, 10);
var scale = parseFloat(weexEnv.scale, 10) || DEFAULT_SCALE;
if (landscape) {
dimensions = {
window: {
width: (weexEnv.deviceHeight * 750 / weexEnv.deviceWidth).toFixed(),
scale: scale,
fontScale: 1
},
screen: {
width: weexEnv.deviceHeight,
height: weexEnv.deviceWidth
}
};
var navbarHeight = 52;
if (scale > 2) {
navbarHeight = 64;
}
dimensions.window.height = (FULL_WIDTH - navbarHeight * scale * FULL_WIDTH / weexEnv.deviceWidth).toFixed();
} else {
scale: scale,
fontScale: 1
},
screen: {
width: weexEnv.deviceHeight,
height: weexEnv.deviceWidth
}
};
var navbarHeight = 52;
if (scale > 2) {
navbarHeight = 64;
}
dimensions.window.height = (FULL_WIDTH - navbarHeight * scale * FULL_WIDTH / weexEnv.deviceWidth).toFixed();
} else {
var height = ((weexEnv.deviceHeight - NAVBAR_HEIGHT * scale) * FULL_WIDTH / weexEnv.deviceWidth).toFixed();
dimensions = {
window: {
width: FULL_WIDTH,
height: height,
scale: scale,
safeHeight: isIphoneXInWeex && isQN ? height - 102 : height,
fontScale: 1
},
screen: {
width: weexEnv.deviceWidth,
height: weexEnv.deviceHeight
}
};
}
} else if (_nukeEnv.isWeb) {
var documentElement = document.documentElement;
var _height = (documentElement.clientHeight * FULL_WIDTH / documentElement.clientWidth).toFixed();
dimensions = {
window: {
width: FULL_WIDTH,
height: _height,
scale: window.devicePixelRatio || DEFAULT_SCALE,
safeHeight: _height,
fontScale: 1
},
screen: screen
};
}
dimensions = {
window: {
width: FULL_WIDTH,
height: ((weexEnv.deviceHeight - NAVBAR_HEIGHT * scale) * FULL_WIDTH / weexEnv.deviceWidth).toFixed(),
scale: scale,
fontScale: 1
},
screen: {
width: weexEnv.deviceWidth,
height: weexEnv.deviceHeight
}
};
}
} else if (_nukeEnv.isWeb) {
var documentElement = document.documentElement;
dimensions = {
window: {
width: FULL_WIDTH,
height: (documentElement.clientHeight * FULL_WIDTH / documentElement.clientWidth).toFixed(),
scale: window.devicePixelRatio || DEFAULT_SCALE,
fontScale: 1
},
screen: screen
};
}
return dimensions;
return dimensions;
}
var Dimensions = function () {
function Dimensions() {
_classCallCheck(this, Dimensions);
}
function Dimensions() {
_classCallCheck(this, Dimensions);
}
_createClass(Dimensions, null, [{
key: 'get',
value: function get(dim) {
return getDimensions()[dim];
}
}, {
key: 'getWindowInfo',
value: function getWindowInfo(landscape) {
return getDimensions(landscape)['window'];
}
}, {
key: 'getScreenInfo',
value: function getScreenInfo(landscape) {
return getDimensions(landscape)['screen'];
}
}]);
_createClass(Dimensions, null, [{
key: 'get',
value: function get(dim) {
return getDimensions()[dim];
}
}, {
key: 'getWindowInfo',
value: function getWindowInfo(landscape) {
return getDimensions(landscape)['window'];
}
}, {
key: 'getScreenInfo',
value: function getScreenInfo(landscape) {
return getDimensions(landscape)['screen'];
}
}]);
return Dimensions;
return Dimensions;
}();

@@ -102,0 +108,0 @@

{
"name": "nuke-dimensions",
"version": "0.1.10",
"version": "0.1.11",
"description": "屏幕参数",
"main": "lib/index",
"files": [
"lib",
"docs",
"theme",
"README.md",
"HISTORY.md"
],
"keywords": [
"nuke",
"dimensions"
],
"files": ["lib", "docs", "theme", "README.md", "HISTORY.md"],
"keywords": ["nuke", "dimensions"],
"author": {

@@ -18,0 +9,0 @@ "name": "doub",

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