Skip to content

Commit

Permalink
Send more info about a layer from the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Mar 8, 2015
1 parent b25c98b commit caca1a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
24 changes: 15 additions & 9 deletions lib/pixel-perfect-actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,19 @@ var PixelPerfectActor = ActorClass(
}

// Get all properties of associate anonymous content
let anonId = "box" + layer.id;
let boxAnonId = "box" + layer.id;
let imageAnonId = layer.id;
let content = layer.content;

result.content = {
style: content.getAttributeForElement(anonId, "style"),
lock: content.getAttributeForElement(anonId, "lock"),
invert: content.getAttributeForElement(anonId, "invert"),
box: {
style: content.getAttributeForElement(boxAnonId, "style"),
lock: content.getAttributeForElement(boxAnonId, "lock"),
invert: content.getAttributeForElement(boxAnonId, "invert"),
},
image: {
style: content.getAttributeForElement(imageAnonId, "style"),
}
}

return result;
Expand Down Expand Up @@ -392,9 +398,9 @@ var PixelPerfectActor = ActorClass(

// Update image box styles
let boxStyle = "";
boxStyle += "left: " + parseInt(layer.x, 10) + "px;";
boxStyle += "top: " + parseInt(layer.y, 10) + "px;";
boxStyle += "display: " + (layer.visible ? "block" : "none") + ";";
boxStyle += "left:" + parseInt(layer.x, 10) + "px;";
boxStyle += "top:" + parseInt(layer.y, 10) + "px;";
boxStyle += "display:" + (layer.visible ? "block" : "none") + ";";
content.setAttributeForElement("box" + layer.id, "style", boxStyle);

if (layer.lock) {
Expand All @@ -411,8 +417,8 @@ var PixelPerfectActor = ActorClass(

// Update image styles
let imageStyle = "";
imageStyle += "opacity: " + (parseInt(layer.opacity, 10) / 100) + ";";
imageStyle += "transform: " + (layer.scale ? "scale(" + layer.scale + ")" : "none") + ";";
imageStyle += "opacity:" + (parseInt(layer.opacity, 10) / 100) + ";";
imageStyle += "transform:" + (layer.scale ? "scale(" + layer.scale + ")" : "none") + ";";
content.setAttributeForElement(layer.id, "style", imageStyle);
}),

Expand Down
4 changes: 2 additions & 2 deletions test/test-layer-invert.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports["test Layer Invert"] = function(assert, done) {
waitForEvents(popup, ["layer-modified"]).then(result => {
// Get layer info from the backend.
popup.front.getLayerInfo(layer.id).then(response => {
assert.equal(response.content.invert, "true",
assert.equal(response.content.box.invert, "true",
"The layer must be inverted");

// Clean up
Expand All @@ -30,7 +30,7 @@ exports["test Layer Invert"] = function(assert, done) {
done();
});
});
})
});
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion test/test-layer-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports["test Layer Lock"] = function(assert, done) {
waitForEvents(popup, ["layer-modified"]).then(() => {
// Get layer info from the backend.
popup.front.getLayerInfo(layer.id).then(response => {
assert.equal(response.content.lock, "true",
assert.equal(response.content.box.lock, "true",
"The layer must be locked");

// Clean up
Expand Down

0 comments on commit caca1a0

Please sign in to comment.