Skip to content

Instantly share code, notes, and snippets.

@alexkaessner
Created February 19, 2019 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkaessner/7939c22ae6a1db74737162ad0979c1be to your computer and use it in GitHub Desktop.
Save alexkaessner/7939c22ae6a1db74737162ad0979c1be to your computer and use it in GitHub Desktop.
Sketch: custom zoom percentage
// 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])
}
@alexkaessner
Copy link
Author

There is now a plug-in available with the same functionality: Custom Zoom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment