Commit 53d8e362 authored by rockyl's avatar rockyl

增加偏移量参数设置

parent ce8ed08c
......@@ -82,6 +82,7 @@ const relativePosPrefixMap = {
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -92,7 +93,9 @@ async function execute(psdFile, options) {
const assets = [];
const imageHashMap = {};
const {width: stageWidth, height: stageHeight} = tree;
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -101,6 +104,7 @@ async function execute(psdFile, options) {
let properties = {
width, height, alpha, visible,
};
const isSecondLayer = !parent.origin.parent;
if (name.includes('|')) {
try {
......@@ -126,10 +130,10 @@ async function execute(psdFile, options) {
if(!hasValue){
switch(fieldChar){
case 'l':
value = x;
value = x - offset.x;
break;
case 't':
value = y;
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
......@@ -183,10 +187,10 @@ async function execute(psdFile, options) {
};
let dealLater = true;
if (x !== 0) {
properties.x = x;
properties.x = x - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y;
properties.y = y - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
This diff is collapsed.
......@@ -88,6 +88,7 @@ const relativePosPrefixMap = {
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -98,7 +99,9 @@ async function execute(psdFile, options) {
const assets = [];
const imageHashMap = {};
const {width: stageWidth, height: stageHeight} = tree;
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -107,6 +110,7 @@ async function execute(psdFile, options) {
let properties = {
width, height, alpha, visible,
};
const isSecondLayer = !parent.origin.parent;
if (name.includes('|')) {
try {
......@@ -132,10 +136,10 @@ async function execute(psdFile, options) {
if(!hasValue){
switch(fieldChar){
case 'l':
value = x;
value = x - offset.x;
break;
case 't':
value = y;
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
......@@ -189,10 +193,10 @@ async function execute(psdFile, options) {
};
let dealLater = true;
if (x !== 0) {
properties.x = x;
properties.x = x - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y;
properties.y = y - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
This diff is collapsed.
......@@ -88,6 +88,7 @@
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -98,7 +99,9 @@
const assets = [];
const imageHashMap = {};
const {width: stageWidth, height: stageHeight} = tree;
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -107,6 +110,7 @@
let properties = {
width, height, alpha, visible,
};
const isSecondLayer = !parent.origin.parent;
if (name.includes('|')) {
try {
......@@ -132,10 +136,10 @@
if(!hasValue){
switch(fieldChar){
case 'l':
value = x;
value = x - offset.x;
break;
case 't':
value = y;
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
......@@ -189,10 +193,10 @@
};
let dealLater = true;
if (x !== 0) {
properties.x = x;
properties.x = x - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y;
properties.y = y - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
This diff is collapsed.
......@@ -29,6 +29,7 @@ const relativePosPrefixMap = {
export async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -39,7 +40,9 @@ export async function execute(psdFile, options) {
const assets = [];
const imageHashMap = {};
const {width: stageWidth, height: stageHeight} = tree;
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -48,6 +51,7 @@ export async function execute(psdFile, options) {
let properties = {
width, height, alpha, visible,
};
const isSecondLayer = !parent.origin.parent;
const {width: parentWidth, height: parentHeight} = parent;
......@@ -75,10 +79,10 @@ export async function execute(psdFile, options) {
if(!hasValue){
switch(fieldChar){
case 'l':
value = x;
value = x - offset.x;
break;
case 't':
value = y;
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
......@@ -132,10 +136,10 @@ export async function execute(psdFile, options) {
};
let dealLater = true;
if (x !== 0) {
properties.x = x;
properties.x = x - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y;
properties.y = y - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment