Created
September 13, 2016 17:36
-
-
Save lucasff/335c04619045f415d82d332f8c3385b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* @ngdoc directive | |
* @name ttmApp.directive:CopyHeight | |
* @description | |
* Set the height of an element base on another element | |
*/ | |
angular.module('ttmApp') | |
.directive('copyHeight', function ($interval, $timeout) { | |
var $ = window.jQuery; | |
var elements = new Set(); | |
var values = []; | |
return { | |
restrict: 'A', | |
scope: { | |
'watchedElement': '=' | |
}, | |
link: function (scope, element, attributes) { | |
function setHeight() { | |
var targetHeight = Array.max(values); | |
console.log(targetHeight); | |
Array.from(elements).forEach(function(item) { | |
item.height(targetHeight); | |
}); | |
} | |
function processElements() { | |
elements.add(element); | |
values.push($('#' + attributes.copyHeight).height()); | |
$timeout(setHeight, 1000); | |
} | |
//$(window).resize(setHeight); | |
//$(window).load(setHeight); | |
$interval(processElements, 500); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment