Skip to content

Commit e46b837

Browse files
committed
Fixed for Sketch 3.3
1 parent 9a9c0cc commit e46b837

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Fit to Width.sketchplugin

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Fit to Width (cmd shift 1)
2+
// This plugin will zoom out to fit the canvas' contents in the window,
3+
// but maximizing the width only
24
margin = 50
35
view = [doc currentView]
46

@@ -12,11 +14,11 @@ layerRect = [view totalRectForLayers:layers]
1214
ratio = window_width / window_height
1315

1416
// Set rect height to new ratio
15-
layerRect.setHeight(layerRect.width() / ratio)
17+
layerRect.size.height = layerRect.size.width / ratio
1618

17-
layerRect.setX(layerRect.x() - margin)
18-
layerRect.setY(layerRect.y() - margin)
19-
layerRect.setWidth(layerRect.width() + margin*2)
20-
layerRect.setHeight(layerRect.height() + margin*2)
19+
layerRect.origin.x -= margin
20+
layerRect.origin.y -= margin
21+
layerRect.size.width += margin*2
22+
layerRect.size.height += margin*2
2123

2224
[view zoomToFitRect:layerRect]

0 commit comments

Comments
 (0)