Skip to content

Instantly share code, notes, and snippets.

@stoplion
Created October 15, 2012 19:46
Show Gist options
  • Select an option

  • Save stoplion/3894831 to your computer and use it in GitHub Desktop.

Select an option

Save stoplion/3894831 to your computer and use it in GitHub Desktop.
keeps things in proportion
(($, window) ->
$.extend $.fn, jproportion: (options) ->
@defaultOptions =
ratio : 1.5
settings = $.extend({}, @defaultOptions, options)
@each (i, el) =>
element_width = $(el).outerWidth()
calculated_height = Math.round(element_width / @defaultOptions.ratio)
$(el).height(calculated_height)
@
) this.jQuery or this.Zepto, this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment