├── Fitter.sketchplugin └── Contents │ └── Sketch │ ├── fitter.js │ └── manifest.json ├── README.md └── screenshots ├── menu.png └── screenshots.sketch /Fitter.sketchplugin/Contents/Sketch/fitter.js: -------------------------------------------------------------------------------- 1 | // COMMANDS 2 | function fitToArtboard(context) { 3 | fitterProcessor(context, 0, 1, 1) 4 | }; 5 | function fitToArtboardWidth(context) { 6 | fitterProcessor(context, 0, 1, null) 7 | }; 8 | function fitToArtboardHeight(context) { 9 | fitterProcessor(context, 0, null, 1) 10 | }; 11 | function fitToArtboardMargin(context) { 12 | var doc = context.document 13 | var margin = [[doc askForUserInput:"Margin" ofType:1 initialValue:"16"] integerValue]; 14 | fitterProcessor(context, margin, 1, 1) 15 | } 16 | function fitToArtboardWidthMargin(context) { 17 | var doc = context.document 18 | var margin = [[doc askForUserInput:"Margin" ofType:1 initialValue:"16"] integerValue]; 19 | fitterProcessor(context, margin, 1, null) 20 | } 21 | function fitToArtboardHeightMargin(context) { 22 | var doc = context.document 23 | var margin = [[doc askForUserInput:"Margin" ofType:1 initialValue:"16"] integerValue]; 24 | fitterProcessor(context, margin, null, 1) 25 | } 26 | function fitToWidest(context) { 27 | var doc = context.document 28 | var selection = context.selection 29 | var selectionCount = selection.count() 30 | 31 | if (selectionCount == 0) { 32 | doc.showMessage("Please select at least two layers/artboards.") 33 | return 34 | } 35 | 36 | var widestLayerWidth = selection[0].frame().width() 37 | 38 | for (i=0;i widestLayerWidth){ 43 | widestLayerWidth = layerWidth 44 | var widestLayer = layer 45 | } 46 | } 47 | var newWidth = widestLayerWidth 48 | 49 | for (i=0;i tallestLayerHeight){ 71 | tallestLayerHeight = layerHeight 72 | var tallestLayer = layer 73 | } 74 | } 75 | var newHeight = tallestLayerHeight 76 | 77 | for (i=0;i Preferences > Keyboard > Shortcuts_. [How to set up Keyboard Shortcuts](http://www.sketchtips.info/articles/custom-shortcuts). 14 | 15 | 16 | ## Installation 17 | 18 | [Install from Sketch Toolbox](http://sketchtoolbox.com/) 19 | -------------------------------------------------------------------------------- /screenshots/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pberrecloth/fitter-sketch-plugin/66a45b8c4e2d8750033817aae5fb7410e4f5888d/screenshots/menu.png -------------------------------------------------------------------------------- /screenshots/screenshots.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pberrecloth/fitter-sketch-plugin/66a45b8c4e2d8750033817aae5fb7410e4f5888d/screenshots/screenshots.sketch --------------------------------------------------------------------------------