Created
February 19, 2019 10:38
-
-
Save alexkaessner/7939c22ae6a1db74737162ad0979c1be to your computer and use it in GitHub Desktop.
Sketch: custom zoom percentage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tested with Sketch 53 | |
var sketch = require('sketch') | |
var doc = sketch.getSelectedDocument() | |
var selectedLayers = doc.selectedLayers | |
var selectedCount = selectedLayers.length | |
// ******* CHANGE THIS VALUE ******* | |
// 100% = 1.0 | |
// 50% = 0.5 | |
// … | |
var customZoom = 0.77 | |
// ********************************* | |
// change the zoom level | |
context.document.setZoomValue(customZoom) | |
// center selected artboard | |
if (selectedCount == 1) { | |
doc.centerOnLayer(selectedLayers.layers[0]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is now a plug-in available with the same functionality: Custom Zoom