24.02.2021, 11:00
Set additional class is bar. This single example will work on multiple elements with the same class.
Code:
$(function(){
if (typeof grp == 'undefined') {
return;
}
$('.bar').each(function(index, wrapel) {
var wrap = $(wrapel);
var addr = wrap.data('object');
var el = wrap.find('.icon');
var height = el.height();
var init = true;
grp.listen(addr, function(object) {
var value = Math.round(object.value * height / 100);
el.css('overflow', 'hidden')
.css('height', value)
.css('margin-top', height - value);
if (init) {
init = false;
setTimeout(function() {
el.css('transition', 'height 1s linear, margin-top 1s linear');
}, 10);
}
}, true);
});
});