Skip to content

Instantly share code, notes, and snippets.

@paulitex
Created June 3, 2010 16:18
Show Gist options
  • Save paulitex/424084 to your computer and use it in GitHub Desktop.
Save paulitex/424084 to your computer and use it in GitHub Desktop.
initMixin: function() {
var resizeF;
var thisView = this;
if (typeof window.onresize === "function"){
resizeF = function(){
window.onresize();
thisView.checkBounds();
};
}
else {
resizeF = function(){
thisView.checkBounds();
};
}
window.onresize = resizeF;
},
checkBounds: function() {
// recompute bounds, so don't get abandoned off screen
var rect = this.computeFrameWithParentFrame(null);
// handle X direction
this.adjust('left', this._checkX(rect.x, (rect.width/2)));
// // handle Y direction
this.adjust('top', this._checkY(rect.y, (rect.height/2)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment