Commit 358bd784 authored by rockyl's avatar rockyl

修复

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