I'm very close to achieving what I want, but my goal is a bit unconventional.
My setup includes several panels divided into 2 columns, with each panel capable of triggering an expand/compress toggle.
My challenge is maintaining the vertical positioning of the element that triggered the toggle, so users can easily keep track of the panel they want to see in expanded mode.
Unfortunately, I haven't been able to figure out how to make the scroll position of lower panels move up when the expand button is clicked.
$('button').click(function () {
var id = $(this).closest('div').attr('id');
var target = $('#' + id);
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
$('.fa-compress').toggle();
$('.fa-expand').toggle();
$('.row > div').toggleClass('col-xs-6').toggleClass('col-xs-12');
});
You can view my progress on JS Fiddle
**UPDATE
For clarity, users will initially see the compressed view (2 column layout), and if they choose to view a specific panel, they can click the expand button. I want the expand animation to happen without affecting the vertical positioning of the triggered panel. This is what I mean by keeping vertical positioning intact.