Commit 358bd784 authored by rockyl's avatar rockyl

修复

parent 53d8e362
......@@ -80,9 +80,24 @@ const relativePosPrefixMap = {
bp: {field: 'bottom', },
};
const offsetAll = 176;
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
const {mode = 'none'} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
if(mode !== 'none'){
cutSize.y = offsetAll;
}
switch(mode){
case 'top':
offset.y = offsetAll;
break;
case 'center':
offset.y = offsetAll / 2;
break;
}
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -94,8 +109,8 @@ async function execute(psdFile, options) {
const imageHashMap = {};
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
stageWidth -= 0;
stageHeight -= cutSize.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -136,10 +151,10 @@ async function execute(psdFile, options) {
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
value = stageWidth - (x - offset.x) - width;
break;
case 'b':
value = stageHeight - height;
value = stageHeight - (y - offset.y) - height;
break;
case 'h':
value = x + width / 2 - stageWidth / 2;
......@@ -187,10 +202,10 @@ async function execute(psdFile, options) {
};
let dealLater = true;
if (x !== 0) {
properties.x = x - (isSecondLayer ? offset.x : 0);
properties.x = x;// - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y - (isSecondLayer ? offset.y : 0);
properties.y = y;// - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
This diff is collapsed.
......@@ -86,9 +86,24 @@ const relativePosPrefixMap = {
bp: {field: 'bottom', },
};
const offsetAll = 176;
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
const {mode = 'none'} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
if(mode !== 'none'){
cutSize.y = offsetAll;
}
switch(mode){
case 'top':
offset.y = offsetAll;
break;
case 'center':
offset.y = offsetAll / 2;
break;
}
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -100,8 +115,8 @@ async function execute(psdFile, options) {
const imageHashMap = {};
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
stageWidth -= 0;
stageHeight -= cutSize.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -142,10 +157,10 @@ async function execute(psdFile, options) {
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
value = stageWidth - (x - offset.x) - width;
break;
case 'b':
value = stageHeight - height;
value = stageHeight - (y - offset.y) - height;
break;
case 'h':
value = x + width / 2 - stageWidth / 2;
......@@ -193,10 +208,10 @@ async function execute(psdFile, options) {
};
let dealLater = true;
if (x !== 0) {
properties.x = x - (isSecondLayer ? offset.x : 0);
properties.x = x;// - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y - (isSecondLayer ? offset.y : 0);
properties.y = y;// - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
This diff is collapsed.
......@@ -86,9 +86,24 @@
bp: {field: 'bottom', },
};
const offsetAll = 176;
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
const {mode = 'none'} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
if(mode !== 'none'){
cutSize.y = offsetAll;
}
switch(mode){
case 'top':
offset.y = offsetAll;
break;
case 'center':
offset.y = offsetAll / 2;
break;
}
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -100,8 +115,8 @@
const imageHashMap = {};
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
stageWidth -= 0;
stageHeight -= cutSize.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -142,10 +157,10 @@
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
value = stageWidth - (x - offset.x) - width;
break;
case 'b':
value = stageHeight - height;
value = stageHeight - (y - offset.y) - height;
break;
case 'h':
value = x + width / 2 - stageWidth / 2;
......@@ -193,10 +208,10 @@
};
let dealLater = true;
if (x !== 0) {
properties.x = x - (isSecondLayer ? offset.x : 0);
properties.x = x;// - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y - (isSecondLayer ? offset.y : 0);
properties.y = y;// - (isSecondLayer ? offset.y : 0);
}
if (typeTool) {
......
This diff is collapsed.
......@@ -27,9 +27,24 @@ const relativePosPrefixMap = {
bp: {field: 'bottom', },
};
const offsetAll = 176;
export async function execute(psdFile, options) {
const tree = await getTree(psdFile);
const offset = options ? options.offset : {x: 0, y: 0};
const {mode = 'none'} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
if(mode !== 'none'){
cutSize.y = offsetAll;
}
switch(mode){
case 'top':
offset.y = offsetAll;
break;
case 'center':
offset.y = offsetAll / 2;
break;
}
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
......@@ -41,8 +56,8 @@ export async function execute(psdFile, options) {
const imageHashMap = {};
let {width: stageWidth, height: stageHeight} = tree;
stageWidth -= offset.x || 0;
stageHeight -= offset.y || 0;
stageWidth -= cutSize.x || 0;
stageHeight -= cutSize.y || 0;
await walkNode(tree, async function (node, parent) {
let {name} = node;
......@@ -85,10 +100,10 @@ export async function execute(psdFile, options) {
value = y - offset.y;
break;
case 'r':
value = stageWidth - width;
value = stageWidth - (x - offset.x) - width;
break;
case 'b':
value = stageHeight - height;
value = stageHeight - (y - offset.y) - height;
break;
case 'h':
value = x + width / 2 - stageWidth / 2;
......@@ -136,10 +151,10 @@ export async function execute(psdFile, options) {
};
let dealLater = true;
if (x !== 0) {
properties.x = x - (isSecondLayer ? offset.x : 0);
properties.x = x;// - (isSecondLayer ? offset.x : 0);
}
if (y !== 0) {
properties.y = y - (isSecondLayer ? offset.y : 0);
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