Skip to content

Instantly share code, notes, and snippets.

@jney
Created October 8, 2009 21:16
Show Gist options
  • Save jney/205433 to your computer and use it in GitHub Desktop.
Save jney/205433 to your computer and use it in GitHub Desktop.
// Zoom
//
// Proportionnaly update font size
//
// Usage :
// $(document).ready(function () {
// $("#zoom-in").zoom("#to-zoom", 1.25);
// $("#zoom-out").zoom("#to-zoom", 0.8);
// });
//
(function($){
$.fn.extend({
zoom: function(e,sz){
$(this).click(function(){
var fs = $(e).css('font-size') || "1em";
var lh = $(e).css('line-height') || "1";
$(e).css('font-size', fs.replace(/(\d+\.*\d*)(\S*)/, ((parseFloat(fs) * sz) + "$2")));
if(lh.match(/px/))
$(e).css('line-height', lh.replace(/(\d+\.*\d*)(\S*)/, ((parseFloat(lh) * sz) + "$2")));
});
}
});
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment