<style>
.overlay-mode{
position: relative;
z-index: 199;
}
.deployzero{cursor:pointer}
.art-tr .t396 ,
.dissolv{
transition: all 0.5s ease-in-out;
overflow: hidden;
}
.dissolv-hide{
opacity: 0;
pointer-events: none;
}
</style>
<script>
$( document ).ready(function() {
let btnText = "Hide";
let percentList = [
[100,30],
[400,30],
[600,30],
[800,40],
[1200,50],
[1500,50]
];
let btnMode= false;
let maxHpercent = 0;
function hideMove(em,pr){
let height = em.find('.t396__artboard').height();
let width = $(window).width();
$.each(percentList,function(index,value){
if (width>value[0]){maxHpercent=value[1]}
});
let mxH = height*(maxHpercent/100);
if(pr){ em.find('.t396').css('max-height', height)
}else{ em.find('.t396').css('max-height', mxH) };
};
setTimeout(function(){
//Добавляем классы к кнопке и основному Zero
$('.deployzero').closest('.t-rec').each(function(){
$(this).addClass('overlay-mode');
let mBlk = $(this).prev('[data-record-type="396"]');
mBlk.addClass('art-tr');hideMove(mBlk);
$(this).find('.tn-atom').attr('data-btn-caption', $(this).find('.tn-atom').text());
});
//При клике на кнопку
$('.deployzero').on('click', function(e) {
let mBlk = $(this).closest('.t-rec').prev('[data-record-type="396"]');
if (!$(this).hasClass('open-mode')) {
$(this).addClass('open-mode');
mBlk.addClass('open-block');
btnMode = true;
hideMove(mBlk,btnMode);
$(this).siblings('.dissolv').addClass('dissolv-hide');
$(this).find('.tn-atom').text(btnText);
} else {
$(this).removeClass('open-mode');
mBlk.removeClass('open-block');
btnMode = false;
hideMove(mBlk,btnMode);
$(this).siblings('.dissolv').removeClass('dissolv-hide');
$(this).find('.tn-atom').text( $(this).find('.tn-atom').attr('data-btn-caption'));
let speed = 400;let top = mBlk.offset().top;
$('html, body').animate({scrollTop: top}, speed);
};
});
}, 1000);
$(window).resize(function() {clearTimeout(window.resizedFinished); window.resizedFinished = setTimeout(function(){
$('.art-tr').each(function(){
let mBlk = $(this);
if ($(this).hasClass('open-block')) { btnMode = true
}else{ btnMode = false};
hideMove(mBlk,btnMode);
});
}, 1000);});
});
</script>