javascript - MooTools Plugin Function for Vertical Alignment -


how 1 write plugin function (class?) in mootools can called on set of elements in order vertical align them? have similar function i've used jquery, , looks this:

  $.fn.valign = function() {     return this.each(function() {       var ah = $(this).height();       var ph = $(this).parent().height();       var mh = (ph - ah) / 2;       $(this).css('margin-top', mh);     });   }; 

i'm bit @ loss how 1 similar in mootools. proper method create class suggested here? not seem improvement on jquery , seems wrong approach. know right way go this?

following info got tim wienk on irc , github, here practical example of how mootools version like:

element.implement('valign', function () {     var ah = this.getsize().y;     var ph = this.getparent().getsize().y;     var mh = (ph - ah) / 2;     this.setstyle('margin-top', mh); });  $$('div').valign(); 

example online: http://jsfiddle.net/btcb8/


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -