Skip to content

Instantly share code, notes, and snippets.

@nicholasspencer
Created August 30, 2012 21:50
Show Gist options
  • Save nicholasspencer/3542111 to your computer and use it in GitHub Desktop.
Save nicholasspencer/3542111 to your computer and use it in GitHub Desktop.
FUCKING VERTICAL ALIGN FIX
var MMThunderDomeContestantView = MatchbookView.extend({
initialize: function () {
this.parent = this.options.parent || {};
this.model = this.options.model || new App.Model.Profile();
}
, template: function () {
if (this._template) return this._template;
this._template = Handlebars.compile($("#mm-thunderdome-contestant-tmpl").html());
return this._template;
}
, render: function () {
this.$el.html(this.template()(this.model.toJSON()));
this.$("img").bind("load", _.bind(this.fixImagePosition,this));
return this;
}
, fixImagePosition: function (e) {
$target = $(e.currentTarget);
var maxHeight = parseInt($target.css("max-height"));
var height = $target.height();
console.log(maxHeight + " - " + height);
if (maxHeight == height) return;
$target.css("margin-top", (maxHeight - height) * .5);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment