Skip to content

Commit

Permalink
add Align vertical and horzonial center relative to key object
Browse files Browse the repository at this point in the history
  • Loading branch information
LucienLee committed Jan 25, 2015
1 parent ce19c77 commit 11366c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// (cmd option control a)
#import 'utility.js'

align("center")
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Select all layers you want to align, then select `Plugins ▸ AlignTo` in the Sk
- Align bottom relative to key object: `CMD` + `Option` + `Ctrl` + `b`
- Align horzonial center relative to key object: `CMD` + `Option` + `Ctrl` + `h`
- Align vertical center relative to key object: `CMD` + `Option` + `Ctrl` + `v`
- Align vertical and horzonial center relative to key object: `CMD` + `Option` + `Ctrl` + `a`

###Change Shortcut
Open `AlignTo` directory, then open any `*.sketchplugin` file with text editor. Change shortcut you want in the first line.
Expand Down
10 changes: 10 additions & 0 deletions utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ function align(direction){
[frame setMidX:keyCoordinate]
}
break;
case "center":
var getKeyPosition = function(keyFrame) {
keyCoordinateX = [keyFrame midX]
keyCoordinateY = [keyFrame midY]
}
var alignObj = function(frame){
[frame setMidX:keyCoordinateX]
[frame setMidY:keyCoordinateY]
}
break;
}

var choice = createSelect('Align ' + direction +' relative to', layers, 0)
Expand Down

0 comments on commit 11366c5

Please sign in to comment.