Permalink
Browse files

Reset artboard coordinates to leftmost layer

  • Loading branch information...
Koen Bok
Koen Bok committed Dec 18, 2015
1 parent d8cabe8 commit 6b2f999dec71443a018eac5a1da48a61ab852fed
@@ -173,18 +173,20 @@ class exports.Importer
_correctArtboards: (layers) ->
points = []
leftMostLayer = null
for layer in layers
if layer._info.kind is "artboard"
layer.point = layer._info.layerFrame
layer.visible = true
points.push(layer.point)
if leftMostLayer is null or layer.x < leftMostLayer.x
leftMostLayer = layer
return unless leftMostLayer
# Calculate the artboard positions to always be 0,0.
pointOffset =
x: Math.min.apply(@, points.map (p) -> p.x)
y: Math.min.apply(@, points.map (p) -> p.y)
pointOffset = leftMostLayer.point
# Correct the artboard positions to 0,0.
for layer in layers
Binary file not shown.
@@ -0,0 +1,20 @@
{
"screenB": {
"frame": {
"x": 0,
"y": 0,
"width": 375,
"height": 667
},
"subLayerNames": []
},
"screenA": {
"frame": {
"x": 475,
"y": -200,
"width": 375,
"height": 667
},
"subLayerNames": []
}
}
@@ -0,0 +1,52 @@
[
{
"children": [],
"id": "216BB552-1D6F-46DC-9454-8290DCC7E144",
"image": {
"frame": {
"height": 667,
"width": 375,
"x": 443,
"y": 600
},
"path": "images/Layer-screenB-216BB552-1D6F-46DC-9454-8290DCC7E144.png"
},
"imageType": "png",
"kind": "artboard",
"layerFrame": {
"height": 667,
"width": 375,
"x": 443,
"y": 600
},
"maskFrame": null,
"metadata": {},
"name": "screenB",
"visible": true
},
{
"children": [],
"id": "C03716FB-BF3B-4059-8178-197728793CDA",
"image": {
"frame": {
"height": 667,
"width": 375,
"x": 918,
"y": 400
},
"path": "images/Layer-screenA-C03716FB-BF3B-4059-8178-197728793CDA.png"
},
"imageType": "png",
"kind": "artboard",
"layerFrame": {
"height": 667,
"width": 375,
"x": 918,
"y": 400
},
"maskFrame": null,
"metadata": {},
"name": "screenA",
"visible": false
}
]
@@ -0,0 +1,54 @@
window.__imported__ = window.__imported__ || {};
window.__imported__["Screens/layers.json.js"] = [
{
"children": [],
"id": "216BB552-1D6F-46DC-9454-8290DCC7E144",
"image": {
"frame": {
"height": 667,
"width": 375,
"x": 443,
"y": 600
},
"path": "images/Layer-screenB-216BB552-1D6F-46DC-9454-8290DCC7E144.png"
},
"imageType": "png",
"kind": "artboard",
"layerFrame": {
"height": 667,
"width": 375,
"x": 443,
"y": 600
},
"maskFrame": null,
"metadata": {},
"name": "screenB",
"visible": true
},
{
"children": [],
"id": "C03716FB-BF3B-4059-8178-197728793CDA",
"image": {
"frame": {
"height": 667,
"width": 375,
"x": 918,
"y": 400
},
"path": "images/Layer-screenA-C03716FB-BF3B-4059-8178-197728793CDA.png"
},
"imageType": "png",
"kind": "artboard",
"layerFrame": {
"height": 667,
"width": 375,
"x": 918,
"y": 400
},
"maskFrame": null,
"metadata": {},
"name": "screenA",
"visible": false
}
]
@@ -55,6 +55,9 @@ describe "ExternalDocument", ->
it "innermasks@1x", ->
compareDocument "innermasks@1x"
it "Screens@1x", ->
compareDocument "Screens@1x"
describe "Shady Hacks", ->
it "Should work on Chrome", ->

0 comments on commit 6b2f999

Please sign in to comment.