yalabot / angular-foundation

http://pineconellc.github.io/angular-foundation/
Other
1.05k stars 267 forks source link

Equalizer #200

Closed aaronklaser closed 9 years ago

aaronklaser commented 9 years ago

Not really an issue, just no time to properly contribute. I wrote an equalizer directive and wanted to share it.

(function () { 'use strict';

angular.module('directive.equalizer', []);

angular.module('directive.equalizer').directive('equalizer', equalizerDirective);

equalizerDirective.$inject = [];

function equalizerDirective() {
    return {
        restrict: 'A',
        link: link
    }
}

// equalizer on container ==> equalizer-watch on all children inside equalizer. Height will match the tallest child.
var link = function(scope, element, attrs){
    var items = element.find('[equalizer-watch]');
    var biggest = _.max(items, function(e){ return e.clientHeight; });
    element.find('[equalizer-watch]').css('height', biggest.clientHeight);
}

})();

jbrowning commented 9 years ago

Thanks for the info @aaronklaser. Please open a Pull Request if you'd like to contribute this to the project.