Permalink
Browse files

Add center shortcuts

  • Loading branch information...
Koen Bok
Koen Bok committed May 29, 2013
1 parent 2d59000 commit 538806febe5967e9975563aa041e97d450bbc0c6
Showing with 44 additions and 12 deletions.
  1. +24 −7 build/framer.js
  2. +20 −5 src/views/view.coffee
View
@@ -1,7 +1,7 @@
// Framer 2.0-14-gdcd4faa (c) 2013 Koen Bok
// Framer 2.0-15-g2d59000 (c) 2013 Koen Bok
// https://github.com/koenbok/Framer
window.FramerVersion = "2.0-14-gdcd4faa";
window.FramerVersion = "2.0-15-g2d59000";
(function(){var require = function (file, cwd) {
@@ -2434,17 +2434,34 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
});
};
View.prototype.centeredFrame = function() {
View.prototype.centerFrame = function() {
var frame;
frame = this.frame;
if (this.superView) {
frame = this.frame;
frame.midX = this.superView.width / 2.0;
}
if (this.superView) {
frame.midY = this.superView.height / 2.0;
return frame;
} else {
frame = this.frame;
frame.midX = window.innerWidth / 2.0;
frame.midY = window.innerHeight / 2.0;
return frame;
}
return frame;
};
View.prototype.centeredFrame = View.centerFrame;
View.prototype.centerX = function() {
return this.x = this.centerFrame().x;
};
View.prototype.centerY = function() {
return this.y = this.centerFrame().y;
};
View.prototype.center = function() {
return this.frame = this.centerFrame();
};
View.define("width", {
View
@@ -104,13 +104,28 @@ class View extends Frame
width: maxX - minX
height: maxY - minY
centeredFrame: ->
centerFrame: ->
# Get the centered frame for it's superview
frame = @frame
frame.midX = @superView.width / 2.0 if @superView
frame.midY = @superView.height / 2.0 if @superView
frame
if @superView
frame = @frame
frame.midX = @superView.width / 2.0
frame.midY = @superView.height / 2.0
return frame
else
frame = @frame
frame.midX = window.innerWidth / 2.0
frame.midY = window.innerHeight / 2.0
return frame
centeredFrame: @centerFrame
centerX: -> @x = @centerFrame().x
centerY: -> @y = @centerFrame().y
center: -> @frame = @centerFrame()
#############################################################################
## Geometry

0 comments on commit 538806f

Please sign in to comment.